diff --git a/CMakeLists.txt b/CMakeLists.txt index 35132d0e8..943a173ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,6 +143,9 @@ list(APPEND OLIVE_INCLUDE_DIRS ${OPENEXR_INCLUDES}) list(APPEND OLIVE_LIBRARIES olivecore) list(APPEND OLIVE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/core/include) +# Shared header-only utilities (used by both engine/ and app/) +list(APPEND OLIVE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/shared/include) + # Link Qt set(QT_LIBRARIES diff --git a/app/common/filefunctionsapp.cpp b/app/common/filefunctionsapp.cpp index 629753c24..1793675dc 100644 --- a/app/common/filefunctionsapp.cpp +++ b/app/common/filefunctionsapp.cpp @@ -23,7 +23,7 @@ // (common/filefunctions.h) which is on the public include path; these // definitions resolve the symbols locally in the app binary. -#include "common/filefunctions.h" +#include "oakutil/filefunctions.h" #include #include diff --git a/app/common/htmlapp.cpp b/app/common/htmlapp.cpp index ce76c9c77..64af24987 100644 --- a/app/common/htmlapp.cpp +++ b/app/common/htmlapp.cpp @@ -29,12 +29,12 @@ #include #include -#include "common/xmlutils.h" +#include "oakutil/xmlutils.h" #include #include -#include "common/xmlutils.h" +#include "oakutil/xmlutils.h" namespace olive { diff --git a/app/common/qtutilsapp.cpp b/app/common/qtutilsapp.cpp index 8c60290fe..9fff1f5a7 100644 --- a/app/common/qtutilsapp.cpp +++ b/app/common/qtutilsapp.cpp @@ -18,7 +18,7 @@ ***/ -#include "common/qtutils.h" +#include "oakutil/qtutils.h" namespace olive { diff --git a/app/common/xmlutilsapp.cpp b/app/common/xmlutilsapp.cpp index f4ec27d7a..611ad4a23 100644 --- a/app/common/xmlutilsapp.cpp +++ b/app/common/xmlutilsapp.cpp @@ -21,19 +21,19 @@ // App-side implementation of xml_read_next_start_element // Provides a local definition so the app doesn't import this from liboakengine. -#include "common/xmlutils.h" +#include "oakutil/xmlutils.h" namespace olive { bool xml_read_next_start_element(QXmlStreamReader *reader, - CancelAtom *cancel_atom) + void *cancel_atom) { QXmlStreamReader::TokenType token; while ((token = reader->readNext()) != QXmlStreamReader::Invalid && token != QXmlStreamReader::EndDocument && - (!cancel_atom || !cancel_atom->is_cancelled())) { + (!cancel_atom)) { if (reader->isEndElement()) { return false; } else if (reader->isStartElement()) { diff --git a/app/core.cpp b/app/core.cpp index d117313b6..0f1239c7c 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -47,8 +47,8 @@ #endif #include "dialog/task/task.h" -#include "common/filefunctions.h" -#include "common/xmlutils.h" +#include "oakutil/filefunctions.h" +#include "oakutil/xmlutils.h" #include "common/configwrapper.h" #include "dialog/about/about.h" #include "dialog/autorecovery/autorecoverydialog.h" diff --git a/app/crashhandler/crashhandler.cpp b/app/crashhandler/crashhandler.cpp index 70fa7c42b..349044d51 100644 --- a/app/crashhandler/crashhandler.cpp +++ b/app/crashhandler/crashhandler.cpp @@ -37,8 +37,8 @@ #include #include -#include "common/crashpadutils.h" -#include "common/filefunctions.h" +#include "oakutil/crashpadutils.h" +#include "oakutil/filefunctions.h" #include "version.h" namespace olive diff --git a/app/crashhandler/crashhandler.h b/app/crashhandler/crashhandler.h index 57a41a6b0..c07b40a02 100644 --- a/app/crashhandler/crashhandler.h +++ b/app/crashhandler/crashhandler.h @@ -29,7 +29,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/dialog/about/about.h b/app/dialog/about/about.h index 9ecd30505..4f8853d9b 100644 --- a/app/dialog/about/about.h +++ b/app/dialog/about/about.h @@ -25,7 +25,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/dialog/about/scrollinglabel.cpp b/app/dialog/about/scrollinglabel.cpp index 796cac237..6e8d6eed1 100644 --- a/app/dialog/about/scrollinglabel.cpp +++ b/app/dialog/about/scrollinglabel.cpp @@ -23,7 +23,7 @@ #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" namespace olive { diff --git a/app/dialog/actionsearch/actionsearch.h b/app/dialog/actionsearch/actionsearch.h index 645954536..f66b4ae09 100644 --- a/app/dialog/actionsearch/actionsearch.h +++ b/app/dialog/actionsearch/actionsearch.h @@ -28,7 +28,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/dialog/autorecovery/autorecoverydialog.h b/app/dialog/autorecovery/autorecoverydialog.h index 16f5ccf97..f15a5f677 100644 --- a/app/dialog/autorecovery/autorecoverydialog.h +++ b/app/dialog/autorecovery/autorecoverydialog.h @@ -25,7 +25,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/dialog/color/colordialog.cpp b/app/dialog/color/colordialog.cpp index 7553fc0d6..94e2fc4c1 100644 --- a/app/dialog/color/colordialog.cpp +++ b/app/dialog/color/colordialog.cpp @@ -25,7 +25,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" namespace olive { diff --git a/app/dialog/export/codec/av1section.cpp b/app/dialog/export/codec/av1section.cpp index cfb0fe827..a46f06f50 100644 --- a/app/dialog/export/codec/av1section.cpp +++ b/app/dialog/export/codec/av1section.cpp @@ -26,7 +26,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "widget/slider/integerslider.h" namespace olive diff --git a/app/dialog/export/codec/h264section.cpp b/app/dialog/export/codec/h264section.cpp index 79d295daa..c28c8a1d8 100644 --- a/app/dialog/export/codec/h264section.cpp +++ b/app/dialog/export/codec/h264section.cpp @@ -26,7 +26,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "widget/slider/integerslider.h" namespace olive diff --git a/app/dialog/export/export.cpp b/app/dialog/export/export.cpp index f65fcc215..63cc88aac 100644 --- a/app/dialog/export/export.cpp +++ b/app/dialog/export/export.cpp @@ -31,8 +31,8 @@ #include #include -#include "common/digit.h" -#include "common/qtutils.h" +#include "oakutil/digit.h" +#include "oakutil/qtutils.h" #include "codec/exportcodec.h" #include "codec/exportformat.h" #include "dialog/msgbox.h" diff --git a/app/dialog/export/exportaudiotab.h b/app/dialog/export/exportaudiotab.h index e48fa305b..5dfe20499 100644 --- a/app/dialog/export/exportaudiotab.h +++ b/app/dialog/export/exportaudiotab.h @@ -25,7 +25,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" #include "widget/slider/integerslider.h" #include "widget/standardcombos/standardcombos.h" diff --git a/app/dialog/export/exportsubtitlestab.h b/app/dialog/export/exportsubtitlestab.h index 1c0e55e42..a656def6f 100644 --- a/app/dialog/export/exportsubtitlestab.h +++ b/app/dialog/export/exportsubtitlestab.h @@ -26,7 +26,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "dialog/export/exportformatcombobox.h" namespace olive diff --git a/app/dialog/export/exportvideotab.h b/app/dialog/export/exportvideotab.h index 1daeea547..ecd9af026 100644 --- a/app/dialog/export/exportvideotab.h +++ b/app/dialog/export/exportvideotab.h @@ -26,7 +26,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "dialog/export/codec/av1section.h" #include "dialog/export/codec/cineformsection.h" #include "dialog/export/codec/codecstack.h" diff --git a/app/dialog/footageproperties/streamproperties/streamproperties.h b/app/dialog/footageproperties/streamproperties/streamproperties.h index 4dc1a3ad6..36d7dbfb5 100644 --- a/app/dialog/footageproperties/streamproperties/streamproperties.h +++ b/app/dialog/footageproperties/streamproperties/streamproperties.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/dialog/otioproperties/otiopropertiesdialog.h b/app/dialog/otioproperties/otiopropertiesdialog.h index 8397d993b..fd0a9b702 100644 --- a/app/dialog/otioproperties/otiopropertiesdialog.h +++ b/app/dialog/otioproperties/otiopropertiesdialog.h @@ -23,7 +23,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" #include "opentimelineio/timeline.h" #include "node/project/sequence/sequence.h" #include "node/project.h" diff --git a/app/dialog/preferences/keysequenceeditor.h b/app/dialog/preferences/keysequenceeditor.h index f9afdfbf7..e57a70340 100644 --- a/app/dialog/preferences/keysequenceeditor.h +++ b/app/dialog/preferences/keysequenceeditor.h @@ -24,7 +24,7 @@ #include -#include "common/debug.h" +#include "common/debugapp.h" namespace olive { diff --git a/app/dialog/preferences/tabs/preferencesdisktab.cpp b/app/dialog/preferences/tabs/preferencesdisktab.cpp index 29de9f0a4..4df001ddb 100644 --- a/app/dialog/preferences/tabs/preferencesdisktab.cpp +++ b/app/dialog/preferences/tabs/preferencesdisktab.cpp @@ -28,7 +28,7 @@ #include #include -#include "common/filefunctions.h" +#include "oakutil/filefunctions.h" #include "common/configwrapper.h" #include "oakengine/disk.h" #include "olive/core/core.h" diff --git a/app/dialog/preferences/tabs/preferencesgeneraltab.cpp b/app/dialog/preferences/tabs/preferencesgeneraltab.cpp index e033fcbb5..ad3e05fd8 100644 --- a/app/dialog/preferences/tabs/preferencesgeneraltab.cpp +++ b/app/dialog/preferences/tabs/preferencesgeneraltab.cpp @@ -26,7 +26,7 @@ #include #include -#include "common/autoscroll.h" +#include "oakutil/autoscroll.h" #include "core.h" #include "preferencesbehaviortab.h" diff --git a/app/dialog/progress/progress.h b/app/dialog/progress/progress.h index 244074249..12c575953 100644 --- a/app/dialog/progress/progress.h +++ b/app/dialog/progress/progress.h @@ -25,7 +25,7 @@ #include #include -#include "common/debug.h" +#include "common/debugapp.h" #include "widget/taskview/elapsedcounterwidget.h" namespace olive diff --git a/app/dialog/projectimport/projectimporterrordialog.h b/app/dialog/projectimport/projectimporterrordialog.h index 2c447ee17..a1dbd92a0 100644 --- a/app/dialog/projectimport/projectimporterrordialog.h +++ b/app/dialog/projectimport/projectimporterrordialog.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/dialog/projectproperties/projectproperties.cpp b/app/dialog/projectproperties/projectproperties.cpp index 6f047456c..844759eaf 100644 --- a/app/dialog/projectproperties/projectproperties.cpp +++ b/app/dialog/projectproperties/projectproperties.cpp @@ -29,7 +29,7 @@ #include #include -#include "common/filefunctions.h" +#include "oakutil/filefunctions.h" #include "oakengine/color.h" #include "oakengine/disk.h" #include "oakengine/project.h" diff --git a/app/dialog/sequence/presetmanager.h b/app/dialog/sequence/presetmanager.h index da27df6fd..eb371a5e2 100644 --- a/app/dialog/sequence/presetmanager.h +++ b/app/dialog/sequence/presetmanager.h @@ -32,9 +32,9 @@ #include #include -#include "common/define.h" -#include "common/filefunctions.h" -#include "common/xmlutils.h" +#include "oakutil/define.h" +#include "oakutil/filefunctions.h" +#include "oakutil/xmlutils.h" namespace olive { diff --git a/app/dialog/sequence/sequence.cpp b/app/dialog/sequence/sequence.cpp index a224e25b4..8132ab877 100644 --- a/app/dialog/sequence/sequence.cpp +++ b/app/dialog/sequence/sequence.cpp @@ -31,7 +31,7 @@ #include #include "common/configwrapper.h" -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "dialog/msgbox.h" #include "oakengine/node.h" #include "oakengine/timeline.h" diff --git a/app/dialog/sequence/sequencepreset.h b/app/dialog/sequence/sequencepreset.h index 4dfd6b8d7..1be42e325 100644 --- a/app/dialog/sequence/sequencepreset.h +++ b/app/dialog/sequence/sequencepreset.h @@ -25,7 +25,7 @@ #include #include -#include "common/xmlutils.h" +#include "oakutil/xmlutils.h" #include "dialog/sequence/presetmanager.h" #include "render/videoparams.h" diff --git a/app/dialog/text/text.h b/app/dialog/text/text.h index aabe47e97..585de5334 100644 --- a/app/dialog/text/text.h +++ b/app/dialog/text/text.h @@ -26,7 +26,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" #include "widget/slider/floatslider.h" namespace olive diff --git a/app/panel/panel.h b/app/panel/panel.h index 045f772d6..8afd64d7a 100644 --- a/app/panel/panel.h +++ b/app/panel/panel.h @@ -28,7 +28,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" #include diff --git a/app/ui/icons/icons.h b/app/ui/icons/icons.h index b2c8e48c5..be99afa21 100644 --- a/app/ui/icons/icons.h +++ b/app/ui/icons/icons.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/ui/style/style.h b/app/ui/style/style.h index 745849b7a..d0feb7e32 100644 --- a/app/ui/style/style.h +++ b/app/ui/style/style.h @@ -25,7 +25,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/audiomonitor/audiomonitor.cpp b/app/widget/audiomonitor/audiomonitor.cpp index 15e8477b3..730d58050 100644 --- a/app/widget/audiomonitor/audiomonitor.cpp +++ b/app/widget/audiomonitor/audiomonitor.cpp @@ -27,9 +27,9 @@ #include "audio/audiolevelmeter.h" #include "audio/audiomanager.h" -#include "common/decibel.h" +#include "oakutil/decibel.h" #include "oakengine/preview.h" -#include "common/qtutils.h" +#include "oakutil/qtutils.h" namespace olive { diff --git a/app/widget/audiomonitor/audiomonitor.h b/app/widget/audiomonitor/audiomonitor.h index 3d4b9335c..311b069e9 100644 --- a/app/widget/audiomonitor/audiomonitor.h +++ b/app/widget/audiomonitor/audiomonitor.h @@ -27,7 +27,7 @@ #include #include "audio/audiovisualwaveform.h" -#include "common/define.h" +#include "oakutil/define.h" #include "render/audiowaveformcache.h" namespace olive diff --git a/app/widget/clickablelabel/clickablelabel.h b/app/widget/clickablelabel/clickablelabel.h index 87e0d41bd..0b8992927 100644 --- a/app/widget/clickablelabel/clickablelabel.h +++ b/app/widget/clickablelabel/clickablelabel.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/collapsebutton/collapsebutton.h b/app/widget/collapsebutton/collapsebutton.h index 7959a4fd6..a1e358863 100644 --- a/app/widget/collapsebutton/collapsebutton.h +++ b/app/widget/collapsebutton/collapsebutton.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/colorbutton/colorbutton.cpp b/app/widget/colorbutton/colorbutton.cpp index f8e5605a6..3a563086e 100644 --- a/app/widget/colorbutton/colorbutton.cpp +++ b/app/widget/colorbutton/colorbutton.cpp @@ -21,7 +21,7 @@ #include "colorbutton.h" -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "dialog/color/colordialog.h" namespace olive diff --git a/app/widget/colorlabelmenu/colorlabelmenu.cpp b/app/widget/colorlabelmenu/colorlabelmenu.cpp index 26a190e16..5c67a7309 100644 --- a/app/widget/colorlabelmenu/colorlabelmenu.cpp +++ b/app/widget/colorlabelmenu/colorlabelmenu.cpp @@ -25,7 +25,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "ui/colorcoding.h" namespace olive diff --git a/app/widget/colorwheel/colorgradientwidget.cpp b/app/widget/colorwheel/colorgradientwidget.cpp index f8ac0dc14..3588748d1 100644 --- a/app/widget/colorwheel/colorgradientwidget.cpp +++ b/app/widget/colorwheel/colorgradientwidget.cpp @@ -23,7 +23,7 @@ #include -#include "common/lerp.h" +#include "oakutil/lerp.h" #include "node/node.h" namespace olive diff --git a/app/widget/colorwheel/colorpreviewbox.cpp b/app/widget/colorwheel/colorpreviewbox.cpp index 44d9724a9..21b047a2b 100644 --- a/app/widget/colorwheel/colorpreviewbox.cpp +++ b/app/widget/colorwheel/colorpreviewbox.cpp @@ -23,7 +23,7 @@ #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" namespace olive { diff --git a/app/widget/colorwheel/colorswatchchooser.cpp b/app/widget/colorwheel/colorswatchchooser.cpp index 0151e5a89..a1dcbb65b 100644 --- a/app/widget/colorwheel/colorswatchchooser.cpp +++ b/app/widget/colorwheel/colorswatchchooser.cpp @@ -23,7 +23,7 @@ #include -#include "common/filefunctions.h" +#include "oakutil/filefunctions.h" #include "widget/menu/menu.h" namespace olive diff --git a/app/widget/columnedgridlayout/columnedgridlayout.h b/app/widget/columnedgridlayout/columnedgridlayout.h index a8522181a..459ae52c7 100644 --- a/app/widget/columnedgridlayout/columnedgridlayout.h +++ b/app/widget/columnedgridlayout/columnedgridlayout.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/curvewidget/curveview.cpp b/app/widget/curvewidget/curveview.cpp index bd5820caf..57b552ae0 100644 --- a/app/widget/curvewidget/curveview.cpp +++ b/app/widget/curvewidget/curveview.cpp @@ -28,10 +28,10 @@ #include #include -#include "common/decibel.h" +#include "oakutil/decibel.h" #include "common/nodevaluehandle.h" #include "common/oakvaluehelper.h" -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "oakengine/node.h" #include "widget/keyframeview/keyframehandle.h" diff --git a/app/widget/curvewidget/curvewidget.cpp b/app/widget/curvewidget/curvewidget.cpp index 3e3b03ce5..9b33a253b 100644 --- a/app/widget/curvewidget/curvewidget.cpp +++ b/app/widget/curvewidget/curvewidget.cpp @@ -28,7 +28,7 @@ #include #include "core.h" -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "node/node.h" #include "common/nodevaluehandle.h" #include "oakengine/node.h" diff --git a/app/widget/focusablelineedit/focusablelineedit.h b/app/widget/focusablelineedit/focusablelineedit.h index 54b2ed891..14aed09a1 100644 --- a/app/widget/focusablelineedit/focusablelineedit.h +++ b/app/widget/focusablelineedit/focusablelineedit.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/keyframeview/keyframeview.cpp b/app/widget/keyframeview/keyframeview.cpp index 3660d1f41..8ef4af8cc 100644 --- a/app/widget/keyframeview/keyframeview.cpp +++ b/app/widget/keyframeview/keyframeview.cpp @@ -27,7 +27,7 @@ #include "common/nodevaluehandle.h" #include "common/oakvaluehelper.h" -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "dialog/keyframeproperties/keyframeproperties.h" #include "keyframehandle.h" #include "node/node.h" diff --git a/app/widget/menu/menu.h b/app/widget/menu/menu.h index 1660504eb..0d2f1f544 100644 --- a/app/widget/menu/menu.h +++ b/app/widget/menu/menu.h @@ -26,7 +26,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp b/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp index a8ce3ceff..ed90a8177 100644 --- a/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp +++ b/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp @@ -23,7 +23,7 @@ #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "core.h" #include "node/node.h" #include "oakengine/node.h" diff --git a/app/widget/nodeparamview/nodeparamviewitem.cpp b/app/widget/nodeparamview/nodeparamviewitem.cpp index 9918db83e..e8fff4ab3 100644 --- a/app/widget/nodeparamview/nodeparamviewitem.cpp +++ b/app/widget/nodeparamview/nodeparamviewitem.cpp @@ -24,7 +24,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "dialog/speedduration/speeddurationdialog.h" #include "node/project/sequence/sequence.h" #include "oakengine/node.h" diff --git a/app/widget/nodeparamview/nodeparamviewtextedit.h b/app/widget/nodeparamview/nodeparamviewtextedit.h index 75ed76c67..09cc86c70 100644 --- a/app/widget/nodeparamview/nodeparamviewtextedit.h +++ b/app/widget/nodeparamview/nodeparamviewtextedit.h @@ -26,7 +26,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp index 3af69ca0d..5376cc3d6 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp @@ -28,7 +28,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "core.h" #include "nodeparambutton.h" #include "node/node.h" diff --git a/app/widget/nodeview/nodeviewcommon.h b/app/widget/nodeview/nodeviewcommon.h index c6562e5c4..e2898d9df 100644 --- a/app/widget/nodeview/nodeviewcommon.h +++ b/app/widget/nodeview/nodeviewcommon.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/nodeview/nodeviewedge.cpp b/app/widget/nodeview/nodeviewedge.cpp index 7625ef94a..3a5861cff 100644 --- a/app/widget/nodeview/nodeviewedge.cpp +++ b/app/widget/nodeview/nodeviewedge.cpp @@ -26,7 +26,7 @@ #include #include -#include "common/lerp.h" +#include "oakutil/lerp.h" #include "nodeview.h" #include "nodeviewitem.h" #include "nodeviewscene.h" diff --git a/app/widget/nodeview/nodeviewitem.cpp b/app/widget/nodeview/nodeviewitem.cpp index a3b586db3..542e5fe04 100644 --- a/app/widget/nodeview/nodeviewitem.cpp +++ b/app/widget/nodeview/nodeviewitem.cpp @@ -29,7 +29,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "common/configwrapper.h" #include "core.h" #include "node/value.h" diff --git a/app/widget/path/pathwidget.cpp b/app/widget/path/pathwidget.cpp index 00e15e0c0..094b77082 100644 --- a/app/widget/path/pathwidget.cpp +++ b/app/widget/path/pathwidget.cpp @@ -25,7 +25,7 @@ #include #include -#include "common/filefunctions.h" +#include "oakutil/filefunctions.h" namespace olive { diff --git a/app/widget/path/pathwidget.h b/app/widget/path/pathwidget.h index fc9820937..361e56672 100644 --- a/app/widget/path/pathwidget.h +++ b/app/widget/path/pathwidget.h @@ -25,7 +25,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/playbackcontrols/dragbutton.h b/app/widget/playbackcontrols/dragbutton.h index cab350bcf..b02be03db 100644 --- a/app/widget/playbackcontrols/dragbutton.h +++ b/app/widget/playbackcontrols/dragbutton.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index e5584d310..c4ae37128 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -30,7 +30,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" #include "core.h" #include "dialog/footageproperties/footageproperties.h" #include "dialog/proxy/proxydialog.h" diff --git a/app/widget/projectexplorer/projectexplorericonviewitemdelegate.cpp b/app/widget/projectexplorer/projectexplorericonviewitemdelegate.cpp index 692ddf4ce..24fa5e242 100644 --- a/app/widget/projectexplorer/projectexplorericonviewitemdelegate.cpp +++ b/app/widget/projectexplorer/projectexplorericonviewitemdelegate.cpp @@ -23,7 +23,7 @@ #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" namespace olive { diff --git a/app/widget/projectexplorer/projectexplorericonviewitemdelegate.h b/app/widget/projectexplorer/projectexplorericonviewitemdelegate.h index d7c2d01e3..bcbf5cf29 100644 --- a/app/widget/projectexplorer/projectexplorericonviewitemdelegate.h +++ b/app/widget/projectexplorer/projectexplorericonviewitemdelegate.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/projectexplorer/projectexplorerlistviewbase.h b/app/widget/projectexplorer/projectexplorerlistviewbase.h index 2169b573a..0a1d26c01 100644 --- a/app/widget/projectexplorer/projectexplorerlistviewbase.h +++ b/app/widget/projectexplorer/projectexplorerlistviewbase.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/projectexplorer/projectexplorerlistviewitemdelegate.h b/app/widget/projectexplorer/projectexplorerlistviewitemdelegate.h index 7297fdf33..bb0d38a4e 100644 --- a/app/widget/projectexplorer/projectexplorerlistviewitemdelegate.h +++ b/app/widget/projectexplorer/projectexplorerlistviewitemdelegate.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/projectexplorer/projectexplorernavigation.cpp b/app/widget/projectexplorer/projectexplorernavigation.cpp index ea7b90d7f..92175130c 100644 --- a/app/widget/projectexplorer/projectexplorernavigation.cpp +++ b/app/widget/projectexplorer/projectexplorernavigation.cpp @@ -24,7 +24,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" #include "ui/icons/icons.h" namespace olive diff --git a/app/widget/projectexplorer/projectexplorernavigation.h b/app/widget/projectexplorer/projectexplorernavigation.h index 4bf12fa30..bcba1b06e 100644 --- a/app/widget/projectexplorer/projectexplorernavigation.h +++ b/app/widget/projectexplorer/projectexplorernavigation.h @@ -27,7 +27,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/projectexplorer/projectexplorertreeview.h b/app/widget/projectexplorer/projectexplorertreeview.h index a334c36d5..1631effe7 100644 --- a/app/widget/projectexplorer/projectexplorertreeview.h +++ b/app/widget/projectexplorer/projectexplorertreeview.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/projectexplorer/projectviewmodel.cpp b/app/widget/projectexplorer/projectviewmodel.cpp index f9dc922bb..72440a68a 100644 --- a/app/widget/projectexplorer/projectviewmodel.cpp +++ b/app/widget/projectexplorer/projectviewmodel.cpp @@ -26,7 +26,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "core.h" #include "oakengine/project.h" #include "oakengine/node.h" diff --git a/app/widget/projecttoolbar/projecttoolbar.h b/app/widget/projecttoolbar/projecttoolbar.h index 120968abf..8b9698c86 100644 --- a/app/widget/projecttoolbar/projecttoolbar.h +++ b/app/widget/projecttoolbar/projecttoolbar.h @@ -26,7 +26,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/resizablescrollbar/resizablescrollbar.cpp b/app/widget/resizablescrollbar/resizablescrollbar.cpp index 4c7d1a3ab..a0a8b8b83 100644 --- a/app/widget/resizablescrollbar/resizablescrollbar.cpp +++ b/app/widget/resizablescrollbar/resizablescrollbar.cpp @@ -26,7 +26,7 @@ #include #include -#include "common/range.h" +#include "oakutil/range.h" namespace olive { diff --git a/app/widget/resizablescrollbar/resizablescrollbar.h b/app/widget/resizablescrollbar/resizablescrollbar.h index 7465c29e6..975d5f0e3 100644 --- a/app/widget/resizablescrollbar/resizablescrollbar.h +++ b/app/widget/resizablescrollbar/resizablescrollbar.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/scope/histogram/histogram.cpp b/app/widget/scope/histogram/histogram.cpp index 34e9d4536..8c692d8c5 100644 --- a/app/widget/scope/histogram/histogram.cpp +++ b/app/widget/scope/histogram/histogram.cpp @@ -26,8 +26,8 @@ #include #include -#include "common/qtutils.h" -#include "common/filefunctions.h" +#include "oakutil/qtutils.h" +#include "oakutil/filefunctions.h" #include "oakengine/display.h" namespace olive diff --git a/app/widget/scope/vectorscope/vectorscope.cpp b/app/widget/scope/vectorscope/vectorscope.cpp index 5c3e9258a..04614d889 100644 --- a/app/widget/scope/vectorscope/vectorscope.cpp +++ b/app/widget/scope/vectorscope/vectorscope.cpp @@ -24,8 +24,8 @@ #include #include -#include "common/qtutils.h" -#include "common/filefunctions.h" +#include "oakutil/qtutils.h" +#include "oakutil/filefunctions.h" #include "oakengine/color.h" #include "oakengine/display.h" diff --git a/app/widget/scope/waveform/waveform.cpp b/app/widget/scope/waveform/waveform.cpp index 45d4ecfde..98ca486fa 100644 --- a/app/widget/scope/waveform/waveform.cpp +++ b/app/widget/scope/waveform/waveform.cpp @@ -27,9 +27,9 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "common/configwrapper.h" -#include "common/filefunctions.h" +#include "oakutil/filefunctions.h" #include "oakengine/color.h" #include "oakengine/display.h" diff --git a/app/widget/slider/base/numericsliderbase.cpp b/app/widget/slider/base/numericsliderbase.cpp index 9b5e29eed..b6ea19331 100644 --- a/app/widget/slider/base/numericsliderbase.cpp +++ b/app/widget/slider/base/numericsliderbase.cpp @@ -21,7 +21,7 @@ #include "numericsliderbase.h" -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "common/configwrapper.h" #include "core.h" diff --git a/app/widget/slider/base/sliderbase.cpp b/app/widget/slider/base/sliderbase.cpp index 18a3ac9fe..33d13abb2 100644 --- a/app/widget/slider/base/sliderbase.cpp +++ b/app/widget/slider/base/sliderbase.cpp @@ -25,7 +25,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "core.h" #include "window/mainwindow/mainwindow.h" diff --git a/app/widget/slider/base/sliderlabel.h b/app/widget/slider/base/sliderlabel.h index 7bf4399b6..04d0f059a 100644 --- a/app/widget/slider/base/sliderlabel.h +++ b/app/widget/slider/base/sliderlabel.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/slider/base/sliderladder.cpp b/app/widget/slider/base/sliderladder.cpp index 4f813b90d..c79885c39 100644 --- a/app/widget/slider/base/sliderladder.cpp +++ b/app/widget/slider/base/sliderladder.cpp @@ -32,8 +32,8 @@ #include #endif -#include "common/lerp.h" -#include "common/qtutils.h" +#include "oakutil/lerp.h" +#include "oakutil/qtutils.h" #include "common/configwrapper.h" namespace olive diff --git a/app/widget/slider/base/sliderladder.h b/app/widget/slider/base/sliderladder.h index 01e220279..23fbbee7e 100644 --- a/app/widget/slider/base/sliderladder.h +++ b/app/widget/slider/base/sliderladder.h @@ -26,7 +26,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/slider/floatslider.cpp b/app/widget/slider/floatslider.cpp index dfa08f219..47f45f9ac 100644 --- a/app/widget/slider/floatslider.cpp +++ b/app/widget/slider/floatslider.cpp @@ -24,7 +24,7 @@ #include #include -#include "common/decibel.h" +#include "oakutil/decibel.h" namespace olive { diff --git a/app/widget/taskview/elapsedcounterwidget.h b/app/widget/taskview/elapsedcounterwidget.h index dd2e8f4ba..b711bf1f2 100644 --- a/app/widget/taskview/elapsedcounterwidget.h +++ b/app/widget/taskview/elapsedcounterwidget.h @@ -26,7 +26,7 @@ #include #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/timebased/timebasedviewselectionmanager.h b/app/widget/timebased/timebasedviewselectionmanager.h index 8ad8d5ce2..09b6e426f 100644 --- a/app/widget/timebased/timebasedviewselectionmanager.h +++ b/app/widget/timebased/timebasedviewselectionmanager.h @@ -27,7 +27,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "olive/core/util/timecodefunctions.h" #include "oakengine/node.h" #include "oakengine/undo.h" diff --git a/app/widget/timebased/timebasedwidget.cpp b/app/widget/timebased/timebasedwidget.cpp index c01c86432..25c256630 100644 --- a/app/widget/timebased/timebasedwidget.cpp +++ b/app/widget/timebased/timebasedwidget.cpp @@ -23,8 +23,8 @@ #include -#include "common/autoscroll.h" -#include "common/range.h" +#include "oakutil/autoscroll.h" +#include "oakutil/range.h" #include "common/configwrapper.h" #include "core.h" #include "engineeventbridge.h" diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index 5c5202fc1..2932023d7 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -40,7 +40,7 @@ #include "oakengine/audio.h" #include "core.h" #include "engineeventbridge.h" -#include "common/range.h" +#include "oakutil/range.h" #include "dialog/proxy/proxydialog.h" #include "dialog/sequence/sequence.h" #include "dialog/speedduration/speeddurationdialog.h" diff --git a/app/widget/timelinewidget/tool/import.cpp b/app/widget/timelinewidget/tool/import.cpp index ac21b465a..d3b7b6c9a 100644 --- a/app/widget/timelinewidget/tool/import.cpp +++ b/app/widget/timelinewidget/tool/import.cpp @@ -27,7 +27,7 @@ #include #include "common/configwrapper.h" -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "core.h" #include "dialog/sequence/sequence.h" #include "node/audio/volume/volume.h" diff --git a/app/widget/timelinewidget/tool/pointer.cpp b/app/widget/timelinewidget/tool/pointer.cpp index 621703147..75c3af9f7 100644 --- a/app/widget/timelinewidget/tool/pointer.cpp +++ b/app/widget/timelinewidget/tool/pointer.cpp @@ -24,8 +24,8 @@ #include #include -#include "common/qtutils.h" -#include "common/range.h" +#include "oakutil/qtutils.h" +#include "oakutil/range.h" #include "common/configwrapper.h" #include "core.h" #include "node/block/gap/gap.h" diff --git a/app/widget/timelinewidget/trackview/trackviewsplitter.h b/app/widget/timelinewidget/trackview/trackviewsplitter.h index 7c7e0e7cf..7613176ee 100644 --- a/app/widget/timelinewidget/trackview/trackviewsplitter.h +++ b/app/widget/timelinewidget/trackview/trackviewsplitter.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/timelinewidget/view/timelineview.cpp b/app/widget/timelinewidget/view/timelineview.cpp index 647e8afd3..59d12370e 100644 --- a/app/widget/timelinewidget/view/timelineview.cpp +++ b/app/widget/timelinewidget/view/timelineview.cpp @@ -29,7 +29,7 @@ #include #include "common/configwrapper.h" -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "../../timeruler/markerpainting.h" #include "node/project/footage/footage.h" #include "oakengine/timeline.h" diff --git a/app/widget/timeruler/markerpainting.cpp b/app/widget/timeruler/markerpainting.cpp index 0d120b651..8860124a7 100644 --- a/app/widget/timeruler/markerpainting.cpp +++ b/app/widget/timeruler/markerpainting.cpp @@ -24,7 +24,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "common/colorcodingapp.h" namespace olive diff --git a/app/widget/timeruler/seekablewidget.cpp b/app/widget/timeruler/seekablewidget.cpp index 0b0f1a260..8dc5211eb 100644 --- a/app/widget/timeruler/seekablewidget.cpp +++ b/app/widget/timeruler/seekablewidget.cpp @@ -26,8 +26,8 @@ #include #include -#include "common/qtutils.h" -#include "common/range.h" +#include "oakutil/qtutils.h" +#include "oakutil/range.h" #include "core.h" #include "dialog/markerproperties/markerpropertiesdialog.h" #include "markerpainting.h" diff --git a/app/widget/timeruler/timeruler.cpp b/app/widget/timeruler/timeruler.cpp index c03565eae..9ff769449 100644 --- a/app/widget/timeruler/timeruler.cpp +++ b/app/widget/timeruler/timeruler.cpp @@ -24,7 +24,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "common/configwrapper.h" #include "core.h" #include "oakengine/viewer.h" diff --git a/app/widget/viewer/viewerdisplay.cpp b/app/widget/viewer/viewerdisplay.cpp index 844b1cd07..a8b9815c7 100644 --- a/app/widget/viewer/viewerdisplay.cpp +++ b/app/widget/viewer/viewerdisplay.cpp @@ -38,14 +38,14 @@ #include #include "audio/audiomanager.h" -#include "common/define.h" -#include "common/html.h" +#include "oakutil/define.h" +#include "common/htmlapp.h" #include "oakengine/gizmo.h" #include "oakengine/videoparams.h" #include "oakengine/display.h" #include "oakengine/undo.h" #include "widget/viewer/vieweroutpututils.h" -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "common/configwrapper.h" #include "core.h" #include "node/block/subtitle/subtitle.h" diff --git a/app/widget/viewer/viewerplaybacktimer.h b/app/widget/viewer/viewerplaybacktimer.h index c902a4432..5f84624ac 100644 --- a/app/widget/viewer/viewerplaybacktimer.h +++ b/app/widget/viewer/viewerplaybacktimer.h @@ -23,7 +23,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/viewer/viewersafemargininfo.h b/app/widget/viewer/viewersafemargininfo.h index 6920fc1d1..c684870f3 100644 --- a/app/widget/viewer/viewersafemargininfo.h +++ b/app/widget/viewer/viewersafemargininfo.h @@ -24,7 +24,7 @@ #include -#include "common/define.h" +#include "oakutil/define.h" namespace olive { diff --git a/app/widget/viewer/viewertexteditor.cpp b/app/widget/viewer/viewertexteditor.cpp index fb34290d8..b6586245f 100644 --- a/app/widget/viewer/viewertexteditor.cpp +++ b/app/widget/viewer/viewertexteditor.cpp @@ -30,7 +30,7 @@ #include #include -#include "common/qtutils.h" +#include "oakutil/qtutils.h" #include "ui/icons/icons.h" namespace olive diff --git a/docs/zh/plans/r8-app-pure-abi-cleanup.md b/docs/zh/plans/r8-app-pure-abi-cleanup.md new file mode 100644 index 000000000..d89bd5f40 --- /dev/null +++ b/docs/zh/plans/r8-app-pure-abi-cleanup.md @@ -0,0 +1,108 @@ +# R8 计划:app/ 纯 C ABI 头文件清理 + +> 目标:app/ 下的代码只 include engine/ 的 C 头文件(`oakengine/*.h`), +> 不再 include 任何 engine 内部 C++ 头。 +> 前置:R7 已完成(nm U _ZN5olive = 0,liboakengine.so 导出收口)。 + +--- + +## 1. 纯头工具共享层(shared/) + +### 1.1 新建目录 + +``` +shared/ + include/ + oakutil/ + define.h ← engine/common/define.h + lerp.h ← engine/common/lerp.h + decibel.h ← engine/common/decibel.h + digit.h ← engine/common/digit.h + range.h ← engine/common/range.h + crashpadutils.h ← engine/common/crashpadutils.h + qtutils.h ← engine/common/qtutils.h(声明) + filefunctions.h ← engine/common/filefunctions.h(声明) + xmlutils.h ← 精简版(XMLAttributeLoop 宏 + xml_read_next_start_element) +``` + +### 1.2 CMake 接入 + +顶层 CMakeLists.txt 添加: +```cmake +list(APPEND OLIVE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/shared/include) +``` + +### 1.3 迁移规则 + +- engine/common/ 中被移出的 .h:原位置改为 `#include "oakutil/xxx.h"` 的转发头 + (保持 engine 内部现有 include 路径不断)。 +- app/ 中所有 `#include "common/xxx.h"`(指 engine 的)改为 `#include "oakutil/xxx.h"`。 +- qtutils.h / filefunctions.h:声明移到 shared,.cpp 实现分别留在 + engine/common/(engine 用)和 app/common/(app 用,已有)。 +- xmlutils.h 精简版:只保留 XMLAttributeLoop 宏 + 无 CancelAtom 的函数声明; + engine 内部完整版保留在 engine/common/xmlutils.h(include 精简版 + 追加 + CancelAtom 重载)。 + +### 1.4 验证 + +```bash +grep -rn '#include "common/' app/ | grep -vE '"common/(colorcodingapp|configwrapper|nodevaluehandle|oakvaluehelper|undowrapper|debugapp|filefunctionsapp|hashstreamapp|htmlapp|qtutilsapp|xmlutilsapp)' +# 期望:0 结果 +``` + +--- + +## 2. engine/ui/colorcoding.h → app 本地化 + +engine/ui/colorcoding.h 是 C++ 类(ColorCoding),被 app 5 处引用。 +方案:在 app/common/ 下新建 `colorcoding.h`,通过 C ABI 或本地静态表实现。 +engine 内部保留原文件。 + +--- + +## 3. engine C++ 类 → C ABI 替换(按子系统) + +按影响面排序,每批一个 PR: + +| 批次 | 子系统 | 违规 include | 替换方案 | +|---|---|---|---| +| P2 | node/value.h + node/keyframe.h | ~10 处 | oakengine/node.h 的 oak_node_value_type 枚举 | +| P3 | node/node.h + node/param.h | ~20 处 | OakEngineNode* + oakengine_node_* 函数 | +| P4 | node/project*.h | ~15 处 | OakEngineProject*/OakEngineSequence* | +| P5 | render/* | ~10 处 | oakengine/display.h + viewer.h | +| P6 | timeline/* | ~6 处 | oakengine/timeline.h | +| P7 | codec/* + audio/* | ~10 处 | oakengine/encoding.h + audio.h | +| P8 | tool/* + undo/* | ~20 处 | 新增 C ABI 或 app 本地枚举 | +| P9 | pluginSupport/* | ~6 处 | oakengine/plugin.h | + +--- + +## 4. CMake 收口(最终步骤) + +- 移除 `target_link_libraries(olive-editor PRIVATE oakengine-obj)` +- 从 `oakengine` 共享库 PUBLIC include 中移除 engine 根目录 +- 只保留 `engine/include`(C ABI 头) + +验证: +```bash +grep -rn '#include "' app/ | grep -E '"(node|render|timeline|codec|audio|task|undo|tool|pluginSupport|ui/colorcoding)/' +# 期望:0 结果 +cmake --build build && ctest --test-dir build --output-on-failure +``` + +--- + +## 状态 + +- [x] Phase 1:shared/ 纯头工具层(define, lerp, decibel, digit, range, crashpadutils, qtutils, filefunctions, xmlutils, autoscroll) +- [ ] Phase 2-9:C++ 类替换(node/, render/, timeline/, codec/, audio/, task/, undo/, tool/, pluginSupport/) +- [ ] Phase 10:CMake 收口 + +### Phase 1 已知遗留 + +- `app/widget/timebased/timebasedwidget.cpp` 仍引用 `common/current.h`(依赖 pluginSupport + render,需 Phase 2+ 处理) +- app/ 仍引用 3 个 engine 内部头(不在 Phase 1 清单内,待后续阶段处理): + `common/commandlineparser.h`(app/main.cpp)、`common/crashpadinterface.h`(app/main.cpp)、 + `common/dropworkflowbehavior.h`(app/widget/timelinewidget/tool/import.h) +- `engine/node/project.h` 原先经 `common/xmlutils.h` 间接获得 `NodeGroup` 前置声明, + 精简后已改为在 project.h 内显式前置声明 diff --git a/engine/common/autoscroll.h b/engine/common/autoscroll.h index 425acc628..8ff4a0c2b 100644 --- a/engine/common/autoscroll.h +++ b/engine/common/autoscroll.h @@ -1,37 +1,2 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#ifndef OAK_AUTOSCROLL_H -#define OAK_AUTOSCROLL_H - -#include "common/define.h" - -namespace olive -{ - -class AutoScroll { -public: - enum Method { k_none, k_page, k_smooth }; -}; - -} - -#endif // OAK_AUTOSCROLL_H +// Forwarding header - canonical content moved to shared/include/oakutil/autoscroll.h +#include "oakutil/autoscroll.h" diff --git a/engine/common/crashpadutils.h b/engine/common/crashpadutils.h index 018936e0e..0e9bc2f70 100644 --- a/engine/common/crashpadutils.h +++ b/engine/common/crashpadutils.h @@ -1,41 +1,2 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#ifndef OAK_CRASHPADUTILS_H -#define OAK_CRASHPADUTILS_H - -#include - -// Copied from base::FilePath to match its macro -#if BUILDFLAG(IS_POSIX) -// On most platforms, native pathnames are char arrays, and the encoding -// may or may not be specified. On Mac OS X, native pathnames are encoded -// in UTF-8. -#define QSTRING_TO_BASE_STRING(x) x.toStdString() -#define BASE_STRING_TO_QSTRING(x) QString::fromStdString(x) -#elif BUILDFLAG(IS_WIN) -// On Windows, for Unicode-aware applications, native pathnames are wchar_t -// arrays encoded in UTF-16. -#define QSTRING_TO_BASE_STRING(x) x.toStdWString() -#define BASE_STRING_TO_QSTRING(x) QString::fromStdWString(x) -#endif // BUILDFLAG(IS_WIN) - -#endif // OAK_CRASHPADUTILS_H +// Forwarding header - canonical content moved to shared/include/oakutil/crashpadutils.h +#include "oakutil/crashpadutils.h" diff --git a/engine/common/decibel.h b/engine/common/decibel.h index 9918049e3..e4931d99d 100644 --- a/engine/common/decibel.h +++ b/engine/common/decibel.h @@ -1,104 +1,2 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#ifndef OAK_DECIBEL_H -#define OAK_DECIBEL_H - -#include -#include - -//#define ALLOW_RETURNING_INFINITY - -namespace olive -{ - -class Decibel { -public: - // In basically all circumstances, this should calculate to 0.0 linear - static constexpr double minimum = -200.0; - - static double from_linear(double linear) - { - double v = double(20.0) * std::log10(linear); -#ifndef ALLOW_RETURNING_INFINITY - if (std::isinf(v)) { - return minimum; - } -#endif - return v; - } - - static double to_linear(double decibel) - { - double to_linear = std::pow(double(10.0), decibel / double(20.0)); - - // Minimum threshold that we figure is close enough to 0 that we may as well just return 0 - if (to_linear < 0.000001) { - return 0; - } else { - return to_linear; - } - } - - static double from_logarithmic(double logarithmic) - { - if (logarithmic < 0.001) -#ifdef ALLOW_RETURNING_INFINITY - return std::numeric_limits::infinity(); -#else - return minimum; -#endif - else if (logarithmic > 0.99) - return 0; - else - return 20.0 * std::log10(-std::log(1 - logarithmic) / lo_g100); - } - - static double to_logarithmic(double decibel) - { - if (qFuzzyIsNull(decibel)) { - return 1; - } else { - return 1 - std::exp(-std::pow(10.0, decibel / 20.0) * lo_g100); - } - } - - static double linear_to_logarithmic(double linear) - { - return 1 - std::exp(-linear * lo_g100); - } - - static double logarithmic_to_linear(double logarithmic) - { - if (logarithmic > 0.99) { - return 1; - } else { - return -std::log(1 - logarithmic) / lo_g100; - } - } - -private: - static constexpr double lo_g100 = 4.60517018599; -}; - -} - -#endif // OAK_DECIBEL_H +// Forwarding header - canonical content moved to shared/include/oakutil/decibel.h +#include "oakutil/decibel.h" diff --git a/engine/common/define.h b/engine/common/define.h index ca0685550..912f3aa15 100644 --- a/engine/common/define.h +++ b/engine/common/define.h @@ -1,68 +1,2 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#ifndef OAK_OLIVECOMMONDEFINE_H -#define OAK_OLIVECOMMONDEFINE_H - -namespace olive -{ - -/// The minimum size an icon in ProjectExplorer can be -const int k_project_icon_size_minimum = 16; - -/// The maximum size an icon in ProjectExplorer can be -const int k_project_icon_size_maximum = 256; - -/// The default size an icon in ProjectExplorer can be -const int k_project_icon_size_default = 64; - -const int k_bytes_in_gigabyte = 1073741824; - -} - -#define MACRO_NAME_AS_STR(s) #s -#define MACRO_VAL_AS_STR(s) MACRO_NAME_AS_STR(s) - -#define OLIVE_NS_CONST_ARG(x, y) \ - QArgument("const " MACRO_VAL_AS_STR(olive) "::" #x, y) -#define OLIVE_NS_ARG(x, y) \ - QArgument(MACRO_VAL_AS_STR(olive) "::" #x, y) -#define OLIVE_NS_RETURN_ARG(x, y) \ - QReturnArgument(MACRO_VAL_AS_STR(olive) "::" #x, y) - -/** - * Copy/move deleters. Similar to Q_DISABLE_COPY_MOVE, et al. but those functions are not present in Qt < 5.13 so we - * use our own functions for portability. - */ - -#define DISABLE_COPY(Class) \ - Class(const Class &) = delete; \ - Class &operator=(const Class &) = delete; - -#define DISABLE_MOVE(Class) \ - Class(Class &&) = delete; \ - Class &operator=(Class &&) = delete; - -#define DISABLE_COPY_MOVE(Class) \ - DISABLE_COPY(Class) \ - DISABLE_MOVE(Class) - -#endif // OAK_OLIVECOMMONDEFINE_H +// Forwarding header - canonical content moved to shared/include/oakutil/define.h +#include "oakutil/define.h" diff --git a/engine/common/digit.h b/engine/common/digit.h index 6801f4dff..fa75e9041 100644 --- a/engine/common/digit.h +++ b/engine/common/digit.h @@ -1,47 +1,2 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#ifndef OAK_DIGIT_H -#define OAK_DIGIT_H - -#include - -namespace olive -{ - -inline int64_t get_digit_count(int64_t input) -{ - input = std::abs(input); - - int64_t lim = 10; - int64_t digit = 1; - - while (input >= lim) { - lim *= 10; - digit++; - } - - return digit; -} - -} - -#endif // OAK_DIGIT_H +// Forwarding header - canonical content moved to shared/include/oakutil/digit.h +#include "oakutil/digit.h" diff --git a/engine/common/filefunctions.h b/engine/common/filefunctions.h index cc25eabba..2d7074a64 100644 --- a/engine/common/filefunctions.h +++ b/engine/common/filefunctions.h @@ -1,109 +1,2 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#ifndef OAK_FILEFUNCTIONS_H -#define OAK_FILEFUNCTIONS_H - -#include -#include - -#include "common/define.h" - -namespace olive -{ - -/** - * @brief A collection of static file and directory functions - */ -class FileFunctions { -public: - /** - * @brief Returns true if the application is running in portable mode - * - * In portable mode, any persistent configuration files should be made in a path relative to the application rather - * than in the user's home folder. - */ - static bool is_portable(); - - static QString get_unique_file_identifier(const QString &filename); - - static QString get_configuration_location(); - - static QString get_application_path(); - - static QString get_temp_file_path(); - - static bool can_copy_directory_without_overwriting(const QString &source, - const QString &dest); - - static void copy_directory(const QString &source, const QString &dest, - bool overwrite = false); - - static bool directory_is_valid(const QDir &dir, - bool try_to_create_if_not_exists = true); - - /** - * @brief Ensures a given filename has a certain extension - * - * Checks if the filename has the extension provided and appends it if not. The extension is - * checked case-insensitive. The extension should be provided with no dot (e.g. "ove" rather than - * ".ove"). - - * @return The filename provided either untouched or with the extension appended to it. - */ - static QString ensure_filename_extension(QString fn, - const QString &extension); - - static QString read_file_as_string(const QString &filename); - - /** - * @brief Returns a temporary filename that can be used while writing rather than the original - * - * If overwriting a file, it's safest to write to a new file first and then only replace it at - * the end so that if the program crashes or the user cancels the save half way through, the - * original file is still intact. - * - * This function returns a slight variant of the filename provided that's guaranteed to not exist - * and therefore won't overwrite anything important. - */ - static QString get_safe_temporary_filename(const QString &original); - - /** - * @brief Renames a file from `from` to `to`, deleting `to` if such a file already exists first - */ - static bool rename_file_allow_overwrite(const QString &from, - const QString &to); - - inline static QString get_formatted_executable_for_platform(QString unformatted) - { -#ifdef Q_OS_WINDOWS - unformatted.append(QStringLiteral(".exe")); -#endif - - return unformatted; - } - - static QString get_auto_recovery_root(); -}; - -} - -#endif // OAK_FILEFUNCTIONS_H +// Forwarding header - canonical content moved to shared/include/oakutil/filefunctions.h +#include "oakutil/filefunctions.h" diff --git a/engine/common/lerp.h b/engine/common/lerp.h index 8b1eb3b0a..b44b8b746 100644 --- a/engine/common/lerp.h +++ b/engine/common/lerp.h @@ -1,42 +1,2 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#ifndef OAK_LERP_H -#define OAK_LERP_H - -template -/** - * @brief Linearly interpolate a value between a and b using t - * - * t should be a number between 0.0 and 1.0. 0.0 will return a, 1.0 will return b, and between will return a value - * in between a and b at that point linearly. - */ -T lerp(T a, T b, double t) -{ - return (a * (1.0 - t)) + (b * t); -} - -template T lerp(T a, T b, float t) -{ - return (a * (1.0f - t)) + (b * t); -} - -#endif // OAK_LERP_H +// Forwarding header - canonical content moved to shared/include/oakutil/lerp.h +#include "oakutil/lerp.h" diff --git a/engine/common/qtutils.h b/engine/common/qtutils.h index f99d57cb9..3212372f1 100644 --- a/engine/common/qtutils.h +++ b/engine/common/qtutils.h @@ -1,113 +1,2 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#ifndef OAK_QTVERSIONABSTRACTION_H -#define OAK_QTVERSIONABSTRACTION_H - -#include -#include -#include -#include -#include -#include - -namespace olive -{ - -class QtUtils { -public: - /** - * @brief Retrieves the width of a string according to certain QFontMetrics - * - * QFontMetrics::width() has been deprecatd in favor of QFontMetrics::horizontalAdvance(), but the - * latter was only introduced in 5.11+. This function wraps the latter for 5.11+ and the former for - * earlier. - */ - static int q_font_metrics_width(QFontMetrics fm, const QString &s); - - static QFrame *create_horizontal_line(); - - static QFrame *create_vertical_line(); - - static QDateTime get_creation_date(const QFileInfo &info); - - static QString get_formatted_date_time(const QDateTime &dt); - - static QStringList word_wrap_string(const QString &s, const QFontMetrics &fm, - int bounding_width); - - static Qt::KeyboardModifiers - flip_control_and_shift_modifiers(Qt::KeyboardModifiers e); - - static void set_combo_box_data(QComboBox *cb, int data); - static void set_combo_box_data(QComboBox *cb, const QString &data); - - template static T *get_parent_of_type(const QObject *child) - { - QObject *t = child->parent(); - - while (t) { - if (T *p = dynamic_cast(t)) { - return p; - } - t = t->parent(); - } - - return nullptr; - } - - static QColor to_q_color(const core::Color &c); - - /** - * @brief Convert a pointer to a value that can be sent between NodeParams - */ - static QVariant ptr_to_value(void *ptr) - { - return reinterpret_cast(ptr); - } - - /** - * @brief Convert a NodeParam value to a pointer of any kind - */ - template static T *value_to_ptr(const QVariant &ptr) - { - return reinterpret_cast(ptr.value()); - } -}; - -namespace core -{ - -uint qHash(const core::Rational &r, uint seed = 0); -uint qHash(const core::TimeRange &r, uint seed = 0); - -} - -} - -Q_DECLARE_METATYPE(olive::core::Rational) -Q_DECLARE_METATYPE(olive::core::Color) -Q_DECLARE_METATYPE(olive::core::TimeRange) -Q_DECLARE_METATYPE(olive::core::Bezier) -Q_DECLARE_METATYPE(olive::core::AudioParams) -Q_DECLARE_METATYPE(olive::core::SampleBuffer) - -#endif // OAK_QTVERSIONABSTRACTION_H +// Forwarding header - canonical content moved to shared/include/oakutil/qtutils.h +#include "oakutil/qtutils.h" diff --git a/engine/common/range.h b/engine/common/range.h index c6ca2f8c0..f05b8a420 100644 --- a/engine/common/range.h +++ b/engine/common/range.h @@ -1,30 +1,2 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#ifndef OAK_RANGE_H -#define OAK_RANGE_H - -template bool in_range(T a, T b, T range) -{ - return (a >= b - range && a <= b + range); -} - -#endif // OAK_RANGE_H +// Forwarding header - canonical content moved to shared/include/oakutil/range.h +#include "oakutil/range.h" diff --git a/engine/common/xmlutils.cpp b/engine/common/xmlutils.cpp index 38ba6b78c..c47820439 100644 --- a/engine/common/xmlutils.cpp +++ b/engine/common/xmlutils.cpp @@ -27,13 +27,14 @@ namespace olive { -bool xml_read_next_start_element(QXmlStreamReader *reader, CancelAtom *cancel_atom) +bool xml_read_next_start_element(QXmlStreamReader *reader, void *cancel_atom) { + CancelAtom *atom = static_cast(cancel_atom); QXmlStreamReader::TokenType token; while ((token = reader->readNext()) != QXmlStreamReader::Invalid && token != QXmlStreamReader::EndDocument && - (!cancel_atom || !cancel_atom->is_cancelled())) { + (!atom || !atom->is_cancelled())) { if (reader->isEndElement()) { return false; } else if (reader->isStartElement()) { diff --git a/engine/common/xmlutils.h b/engine/common/xmlutils.h index b3a9412d8..812de1e76 100644 --- a/engine/common/xmlutils.h +++ b/engine/common/xmlutils.h @@ -22,34 +22,23 @@ #ifndef OAK_XMLREADLOOP_H #define OAK_XMLREADLOOP_H -#include +// Base declarations (XMLAttributeLoop macro + void* overload) from shared layer +#include "oakutil/xmlutils.h" -#include "node/param.h" #include "render/cancelatom.h" -#include "undo/undocommand.h" namespace olive { -class Block; -class Node; -class NodeInput; -class NodeGroup; - -#define XMLAttributeLoop(reader, item) \ - foreach (const QXmlStreamAttribute &item, reader->attributes()) - /** - * @brief Workaround for QXmlStreamReader::readNextStartElement not detecting the end of a document - * - * Since Qt's default function doesn't exit at the end of the document, it ends up consistently - * throwing a "premature end of document" error. We have our own function here that does essentially - * the same thing but fixes that issue. - * - * See also: https://stackoverflow.com/questions/46346450/qt-qxmlstreamreader-always-returns-premature-end-of-document-error + * @brief Engine-internal overload with typed CancelAtom pointer */ -bool xml_read_next_start_element(QXmlStreamReader *reader, - CancelAtom *cancel_atom = nullptr); +inline bool xml_read_next_start_element(QXmlStreamReader *reader, + CancelAtom *cancel_atom) +{ + return xml_read_next_start_element(reader, + static_cast(cancel_atom)); +} } diff --git a/engine/node/project.h b/engine/node/project.h index 07489bc2b..3a9567e1f 100644 --- a/engine/node/project.h +++ b/engine/node/project.h @@ -35,6 +35,8 @@ namespace olive { +class NodeGroup; + /** * @brief A project instance containing all the data pertaining to the user's project * diff --git a/shared/include/oakutil/autoscroll.h b/shared/include/oakutil/autoscroll.h new file mode 100644 index 000000000..b8a40fe03 --- /dev/null +++ b/shared/include/oakutil/autoscroll.h @@ -0,0 +1,37 @@ +/*** + + Oak - Non-Linear Video Editor + Copyright (C) 2022 Olive Team + Modifications Copyright (C) 2025 mikesolar + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef OAK_AUTOSCROLL_H +#define OAK_AUTOSCROLL_H + +#include "oakutil/define.h" + +namespace olive +{ + +class AutoScroll { +public: + enum Method { k_none, k_page, k_smooth }; +}; + +} + +#endif // OAK_AUTOSCROLL_H diff --git a/shared/include/oakutil/crashpadutils.h b/shared/include/oakutil/crashpadutils.h new file mode 100644 index 000000000..c790be80b --- /dev/null +++ b/shared/include/oakutil/crashpadutils.h @@ -0,0 +1,41 @@ +/*** + + Oak - Non-Linear Video Editor + Copyright (C) 2022 Olive Team + Modifications Copyright (C) 2025 mikesolar + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef OAK_CRASHPADUTILS_H +#define OAK_CRASHPADUTILS_H + +#include + +// Copied from base::FilePath to match its macro +#if BUILDFLAG(IS_POSIX) +// On most platforms, native pathnames are char arrays, and the encoding +// may or may not be specified. On Mac OS X, native pathnames are encoded +// in UTF-8. +#define QSTRING_TO_BASE_STRING(x) x.toStdString() +#define BASE_STRING_TO_QSTRING(x) QString::fromStdString(x) +#elif BUILDFLAG(IS_WIN) +// On Windows, for Unicode-aware applications, native pathnames are wchar_t +// arrays encoded in UTF-16. +#define QSTRING_TO_BASE_STRING(x) x.toStdWString() +#define BASE_STRING_TO_QSTRING(x) QString::fromStdWString(x) +#endif // BUILDFLAG(IS_WIN) + +#endif // OAK_CRASHPADUTILS_H diff --git a/shared/include/oakutil/decibel.h b/shared/include/oakutil/decibel.h new file mode 100644 index 000000000..587f0c425 --- /dev/null +++ b/shared/include/oakutil/decibel.h @@ -0,0 +1,104 @@ +/*** + + Oak - Non-Linear Video Editor + Copyright (C) 2022 Olive Team + Modifications Copyright (C) 2025 mikesolar + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef OAK_DECIBEL_H +#define OAK_DECIBEL_H + +#include +#include + +//#define ALLOW_RETURNING_INFINITY + +namespace olive +{ + +class Decibel { +public: + // In basically all circumstances, this should calculate to 0.0 linear + static constexpr double minimum = -200.0; + + static double from_linear(double linear) + { + double v = double(20.0) * std::log10(linear); +#ifndef ALLOW_RETURNING_INFINITY + if (std::isinf(v)) { + return minimum; + } +#endif + return v; + } + + static double to_linear(double decibel) + { + double to_linear = std::pow(double(10.0), decibel / double(20.0)); + + // Minimum threshold that we figure is close enough to 0 that we may as well just return 0 + if (to_linear < 0.000001) { + return 0; + } else { + return to_linear; + } + } + + static double from_logarithmic(double logarithmic) + { + if (logarithmic < 0.001) +#ifdef ALLOW_RETURNING_INFINITY + return std::numeric_limits::infinity(); +#else + return minimum; +#endif + else if (logarithmic > 0.99) + return 0; + else + return 20.0 * std::log10(-std::log(1 - logarithmic) / lo_g100); + } + + static double to_logarithmic(double decibel) + { + if (qFuzzyIsNull(decibel)) { + return 1; + } else { + return 1 - std::exp(-std::pow(10.0, decibel / 20.0) * lo_g100); + } + } + + static double linear_to_logarithmic(double linear) + { + return 1 - std::exp(-linear * lo_g100); + } + + static double logarithmic_to_linear(double logarithmic) + { + if (logarithmic > 0.99) { + return 1; + } else { + return -std::log(1 - logarithmic) / lo_g100; + } + } + +private: + static constexpr double lo_g100 = 4.60517018599; +}; + +} + +#endif // OAK_DECIBEL_H diff --git a/shared/include/oakutil/define.h b/shared/include/oakutil/define.h new file mode 100644 index 000000000..fde70bfa5 --- /dev/null +++ b/shared/include/oakutil/define.h @@ -0,0 +1,68 @@ +/*** + + Oak - Non-Linear Video Editor + Copyright (C) 2022 Olive Team + Modifications Copyright (C) 2025 mikesolar + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef OAK_OLIVECOMMONDEFINE_H +#define OAK_OLIVECOMMONDEFINE_H + +namespace olive +{ + +/// The minimum size an icon in ProjectExplorer can be +const int k_project_icon_size_minimum = 16; + +/// The maximum size an icon in ProjectExplorer can be +const int k_project_icon_size_maximum = 256; + +/// The default size an icon in ProjectExplorer can be +const int k_project_icon_size_default = 64; + +const int k_bytes_in_gigabyte = 1073741824; + +} + +#define MACRO_NAME_AS_STR(s) #s +#define MACRO_VAL_AS_STR(s) MACRO_NAME_AS_STR(s) + +#define OLIVE_NS_CONST_ARG(x, y) \ + QArgument("const " MACRO_VAL_AS_STR(olive) "::" #x, y) +#define OLIVE_NS_ARG(x, y) \ + QArgument(MACRO_VAL_AS_STR(olive) "::" #x, y) +#define OLIVE_NS_RETURN_ARG(x, y) \ + QReturnArgument(MACRO_VAL_AS_STR(olive) "::" #x, y) + +/** + * Copy/move deleters. Similar to Q_DISABLE_COPY_MOVE, et al. but those functions are not present in Qt < 5.13 so we + * use our own functions for portability. + */ + +#define DISABLE_COPY(Class) \ + Class(const Class &) = delete; \ + Class &operator=(const Class &) = delete; + +#define DISABLE_MOVE(Class) \ + Class(Class &&) = delete; \ + Class &operator=(Class &&) = delete; + +#define DISABLE_COPY_MOVE(Class) \ + DISABLE_COPY(Class) \ + DISABLE_MOVE(Class) + +#endif // OAK_OLIVECOMMONDEFINE_H diff --git a/shared/include/oakutil/digit.h b/shared/include/oakutil/digit.h new file mode 100644 index 000000000..538460c6e --- /dev/null +++ b/shared/include/oakutil/digit.h @@ -0,0 +1,48 @@ +/*** + + Oak - Non-Linear Video Editor + Copyright (C) 2022 Olive Team + Modifications Copyright (C) 2025 mikesolar + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef OAK_DIGIT_H +#define OAK_DIGIT_H + +#include +#include + +namespace olive +{ + +inline int64_t get_digit_count(int64_t input) +{ + input = std::abs(input); + + int64_t lim = 10; + int64_t digit = 1; + + while (input >= lim) { + lim *= 10; + digit++; + } + + return digit; +} + +} + +#endif // OAK_DIGIT_H diff --git a/shared/include/oakutil/filefunctions.h b/shared/include/oakutil/filefunctions.h new file mode 100644 index 000000000..aa8a3b193 --- /dev/null +++ b/shared/include/oakutil/filefunctions.h @@ -0,0 +1,109 @@ +/*** + + Oak - Non-Linear Video Editor + Copyright (C) 2022 Olive Team + Modifications Copyright (C) 2025 mikesolar + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef OAK_FILEFUNCTIONS_H +#define OAK_FILEFUNCTIONS_H + +#include +#include + +#include "oakutil/define.h" + +namespace olive +{ + +/** + * @brief A collection of static file and directory functions + */ +class FileFunctions { +public: + /** + * @brief Returns true if the application is running in portable mode + * + * In portable mode, any persistent configuration files should be made in a path relative to the application rather + * than in the user's home folder. + */ + static bool is_portable(); + + static QString get_unique_file_identifier(const QString &filename); + + static QString get_configuration_location(); + + static QString get_application_path(); + + static QString get_temp_file_path(); + + static bool can_copy_directory_without_overwriting(const QString &source, + const QString &dest); + + static void copy_directory(const QString &source, const QString &dest, + bool overwrite = false); + + static bool directory_is_valid(const QDir &dir, + bool try_to_create_if_not_exists = true); + + /** + * @brief Ensures a given filename has a certain extension + * + * Checks if the filename has the extension provided and appends it if not. The extension is + * checked case-insensitive. The extension should be provided with no dot (e.g. "ove" rather than + * ".ove"). + + * @return The filename provided either untouched or with the extension appended to it. + */ + static QString ensure_filename_extension(QString fn, + const QString &extension); + + static QString read_file_as_string(const QString &filename); + + /** + * @brief Returns a temporary filename that can be used while writing rather than the original + * + * If overwriting a file, it's safest to write to a new file first and then only replace it at + * the end so that if the program crashes or the user cancels the save half way through, the + * original file is still intact. + * + * This function returns a slight variant of the filename provided that's guaranteed to not exist + * and therefore won't overwrite anything important. + */ + static QString get_safe_temporary_filename(const QString &original); + + /** + * @brief Renames a file from `from` to `to`, deleting `to` if such a file already exists first + */ + static bool rename_file_allow_overwrite(const QString &from, + const QString &to); + + inline static QString get_formatted_executable_for_platform(QString unformatted) + { +#ifdef Q_OS_WINDOWS + unformatted.append(QStringLiteral(".exe")); +#endif + + return unformatted; + } + + static QString get_auto_recovery_root(); +}; + +} + +#endif // OAK_FILEFUNCTIONS_H diff --git a/shared/include/oakutil/lerp.h b/shared/include/oakutil/lerp.h new file mode 100644 index 000000000..d77075745 --- /dev/null +++ b/shared/include/oakutil/lerp.h @@ -0,0 +1,42 @@ +/*** + + Oak - Non-Linear Video Editor + Copyright (C) 2022 Olive Team + Modifications Copyright (C) 2025 mikesolar + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef OAK_LERP_H +#define OAK_LERP_H + +template +/** + * @brief Linearly interpolate a value between a and b using t + * + * t should be a number between 0.0 and 1.0. 0.0 will return a, 1.0 will return b, and between will return a value + * in between a and b at that point linearly. + */ +T lerp(T a, T b, double t) +{ + return (a * (1.0 - t)) + (b * t); +} + +template T lerp(T a, T b, float t) +{ + return (a * (1.0f - t)) + (b * t); +} + +#endif // OAK_LERP_H diff --git a/shared/include/oakutil/qtutils.h b/shared/include/oakutil/qtutils.h new file mode 100644 index 000000000..f79487bae --- /dev/null +++ b/shared/include/oakutil/qtutils.h @@ -0,0 +1,113 @@ +/*** + + Oak - Non-Linear Video Editor + Copyright (C) 2022 Olive Team + Modifications Copyright (C) 2025 mikesolar + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef OAK_QTVERSIONABSTRACTION_H +#define OAK_QTVERSIONABSTRACTION_H + +#include +#include +#include +#include +#include +#include + +namespace olive +{ + +class QtUtils { +public: + /** + * @brief Retrieves the width of a string according to certain QFontMetrics + * + * QFontMetrics::width() has been deprecatd in favor of QFontMetrics::horizontalAdvance(), but the + * latter was only introduced in 5.11+. This function wraps the latter for 5.11+ and the former for + * earlier. + */ + static int q_font_metrics_width(QFontMetrics fm, const QString &s); + + static QFrame *create_horizontal_line(); + + static QFrame *create_vertical_line(); + + static QDateTime get_creation_date(const QFileInfo &info); + + static QString get_formatted_date_time(const QDateTime &dt); + + static QStringList word_wrap_string(const QString &s, const QFontMetrics &fm, + int bounding_width); + + static Qt::KeyboardModifiers + flip_control_and_shift_modifiers(Qt::KeyboardModifiers e); + + static void set_combo_box_data(QComboBox *cb, int data); + static void set_combo_box_data(QComboBox *cb, const QString &data); + + template static T *get_parent_of_type(const QObject *child) + { + QObject *t = child->parent(); + + while (t) { + if (T *p = dynamic_cast(t)) { + return p; + } + t = t->parent(); + } + + return nullptr; + } + + static QColor to_q_color(const core::Color &c); + + /** + * @brief Convert a pointer to a value that can be sent between NodeParams + */ + static QVariant ptr_to_value(void *ptr) + { + return reinterpret_cast(ptr); + } + + /** + * @brief Convert a NodeParam value to a pointer of any kind + */ + template static T *value_to_ptr(const QVariant &ptr) + { + return reinterpret_cast(ptr.value()); + } +}; + +namespace core +{ + +uint qHash(const core::Rational &r, uint seed = 0); +uint qHash(const core::TimeRange &r, uint seed = 0); + +} + +} + +Q_DECLARE_METATYPE(olive::core::Rational) +Q_DECLARE_METATYPE(olive::core::Color) +Q_DECLARE_METATYPE(olive::core::TimeRange) +Q_DECLARE_METATYPE(olive::core::Bezier) +Q_DECLARE_METATYPE(olive::core::AudioParams) +Q_DECLARE_METATYPE(olive::core::SampleBuffer) + +#endif // OAK_QTVERSIONABSTRACTION_H diff --git a/shared/include/oakutil/range.h b/shared/include/oakutil/range.h new file mode 100644 index 000000000..e981cacf2 --- /dev/null +++ b/shared/include/oakutil/range.h @@ -0,0 +1,30 @@ +/*** + + Oak - Non-Linear Video Editor + Copyright (C) 2022 Olive Team + Modifications Copyright (C) 2025 mikesolar + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef OAK_RANGE_H +#define OAK_RANGE_H + +template bool in_range(T a, T b, T range) +{ + return (a >= b - range && a <= b + range); +} + +#endif // OAK_RANGE_H diff --git a/shared/include/oakutil/xmlutils.h b/shared/include/oakutil/xmlutils.h new file mode 100644 index 000000000..ec75f9e81 --- /dev/null +++ b/shared/include/oakutil/xmlutils.h @@ -0,0 +1,50 @@ +/*** + + Oak - Non-Linear Video Editor + Copyright (C) 2022 Olive Team + Modifications Copyright (C) 2025 mikesolar + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef OAK_XMLUTILS_SHARED_H +#define OAK_XMLUTILS_SHARED_H + +#include + +namespace olive +{ + +#define XMLAttributeLoop(reader, item) \ + foreach (const QXmlStreamAttribute &item, reader->attributes()) + +/** + * @brief Workaround for QXmlStreamReader::readNextStartElement not detecting the end of a document + * + * Since Qt's default function doesn't exit at the end of the document, it ends up consistently + * throwing a "premature end of document" error. We have our own function here that does essentially + * the same thing but fixes that issue. + * + * See also: https://stackoverflow.com/questions/46346450/qt-qxmlstreamreader-always-returns-premature-end-of-document-error + * + * @param cancel_atom Optional pointer to a CancelAtom (from engine) for cancellation support. + * Pass nullptr when calling from app code without engine dependencies. + */ +bool xml_read_next_start_element(QXmlStreamReader *reader, + void *cancel_atom = nullptr); + +} + +#endif // OAK_XMLUTILS_SHARED_H