diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ad8c36..e980582 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,20 +57,18 @@ set(TOUCAN_PLUGINS enable_testing() -find_package(Imath) -find_package(Freetype) find_package(ZLIB) +find_package(minizip) +find_package(Imath) find_package(PNG) find_package(JPEG) find_package(TIFF) find_package(OpenEXR) -find_package(minizip) find_package(OpenColorIO) find_package(OpenImageIO) find_package(OpenFX) find_package(OpenTimelineIO) -find_package(lunasvg) -find_package(dtk) +find_package(feather-tk) include_directories(lib) include_directories(tests) diff --git a/bin/toucan-filmstrip/App.cpp b/bin/toucan-filmstrip/App.cpp index 4778700..7d03f43 100644 --- a/bin/toucan-filmstrip/App.cpp +++ b/bin/toucan-filmstrip/App.cpp @@ -5,34 +5,34 @@ #include -#include -#include +#include +#include #include namespace toucan { void App::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, std::vector& argv) { - std::vector > args; - args.push_back(dtk::CmdLineValueArg::create( + std::vector > args; + args.push_back(feather_tk::CmdLineValueArg::create( _args.input, "input", "Input .otio file.")); - auto outArg = dtk::CmdLineValueArg::create( + auto outArg = feather_tk::CmdLineValueArg::create( _args.output, "output", "Output image file."); args.push_back(outArg); - std::vector > options; - options.push_back(dtk::CmdLineFlagOption::create( + std::vector > options; + options.push_back(feather_tk::CmdLineFlagOption::create( _options.verbose, std::vector{ "-v" }, "Print verbose output.")); - options.push_back(dtk::CmdLineFlagOption::create( + options.push_back(feather_tk::CmdLineFlagOption::create( _options.help, std::vector{ "-h" }, "Print help.")); @@ -53,7 +53,7 @@ namespace toucan {} std::shared_ptr App::create( - const std::shared_ptr&context, + const std::shared_ptr&context, std::vector&argv) { auto out = std::shared_ptr(new App); diff --git a/bin/toucan-filmstrip/App.h b/bin/toucan-filmstrip/App.h index 70cbf77..28c7174 100644 --- a/bin/toucan-filmstrip/App.h +++ b/bin/toucan-filmstrip/App.h @@ -7,17 +7,17 @@ #include #include -#include +#include #include namespace toucan { - class App : public dtk::IApp + class App : public feather_tk::IApp { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, std::vector&); App(); @@ -26,7 +26,7 @@ namespace toucan ~App(); static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, std::vector&); void run() override; diff --git a/bin/toucan-filmstrip/main.cpp b/bin/toucan-filmstrip/main.cpp index d34dd89..9296afc 100644 --- a/bin/toucan-filmstrip/main.cpp +++ b/bin/toucan-filmstrip/main.cpp @@ -3,8 +3,7 @@ #include "App.h" -#include -#include +#include #include @@ -20,8 +19,7 @@ int main(int argc, char** argv) } try { - auto context = dtk::Context::create(); - dtk::coreInit(context); + auto context = feather_tk::Context::create(); auto app = App::create(context, args); app->run(); out = app->getExit(); diff --git a/bin/toucan-render/App.cpp b/bin/toucan-render/App.cpp index 49558c1..a70dc39 100644 --- a/bin/toucan-render/App.cpp +++ b/bin/toucan-render/App.cpp @@ -7,8 +7,8 @@ #include #include -#include -#include +#include +#include #include @@ -45,21 +45,21 @@ namespace toucan } void App::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, std::vector& argv) { - std::vector > args; - args.push_back(dtk::CmdLineValueArg::create( + std::vector > args; + args.push_back(feather_tk::CmdLineValueArg::create( _args.input, "input", "Input .otio file.")); - auto outArg = dtk::CmdLineValueArg::create( + auto outArg = feather_tk::CmdLineValueArg::create( _args.output, "output", "Output image or movie file. Use a dash ('-') to write raw frames or y4m to stdout."); args.push_back(outArg); - std::vector > options; + std::vector > options; std::vector rawList; for (const auto& spec : rawSpecs) { @@ -70,41 +70,41 @@ namespace toucan { y4mList.push_back(spec.first); } - options.push_back(dtk::CmdLineValueOption::create( + options.push_back(feather_tk::CmdLineValueOption::create( _options.videoCodec, std::vector{ "-vcodec" }, "Set the video codec.", _options.videoCodec, - dtk::join(ffmpeg::getVideoCodecStrings(), ", "))); - options.push_back(dtk::CmdLineFlagOption::create( + feather_tk::join(ffmpeg::getVideoCodecStrings(), ", "))); + options.push_back(feather_tk::CmdLineFlagOption::create( _options.printStart, std::vector{ "-print_start" }, "Print the timeline start time and exit.")); - options.push_back(dtk::CmdLineFlagOption::create( + options.push_back(feather_tk::CmdLineFlagOption::create( _options.printDuration, std::vector{ "-print_duration" }, "Print the timeline duration and exit.")); - options.push_back(dtk::CmdLineFlagOption::create( + options.push_back(feather_tk::CmdLineFlagOption::create( _options.printRate, std::vector{ "-print_rate" }, "Print the timeline frame rate and exit.")); - options.push_back(dtk::CmdLineFlagOption::create( + options.push_back(feather_tk::CmdLineFlagOption::create( _options.printSize, std::vector{ "-print_size" }, "Print the timeline image size.")); - options.push_back(dtk::CmdLineValueOption::create( + options.push_back(feather_tk::CmdLineValueOption::create( _options.raw, std::vector{ "-raw" }, "Raw pixel format to send to stdout.", _options.raw, - dtk::join(rawList, ", "))); - options.push_back(dtk::CmdLineValueOption::create( + feather_tk::join(rawList, ", "))); + options.push_back(feather_tk::CmdLineValueOption::create( _options.y4m, std::vector{ "-y4m" }, "y4m format to send to stdout.", _options.y4m, - dtk::join(y4mList, ", "))); - options.push_back(dtk::CmdLineFlagOption::create( + feather_tk::join(y4mList, ", "))); + options.push_back(feather_tk::CmdLineFlagOption::create( _options.verbose, std::vector{ "-v" }, "Print verbose output.")); @@ -144,7 +144,7 @@ namespace toucan } std::shared_ptr App::create( - const std::shared_ptr& context, + const std::shared_ptr& context, std::vector& argv) { auto out = std::shared_ptr(new App); @@ -320,7 +320,7 @@ namespace toucan { const OTIO_NS::TimeRange timeRange = _timelineWrapper->getTimeRange(); - const auto r = dtk::toRational(timeRange.duration().rate()); + const auto r = feather_tk::toRational(timeRange.duration().rate()); std::stringstream ss; ss << " F" << r.first << ":" << r.second; s = ss.str(); diff --git a/bin/toucan-render/App.h b/bin/toucan-render/App.h index 436fe86..6593883 100644 --- a/bin/toucan-render/App.h +++ b/bin/toucan-render/App.h @@ -7,7 +7,7 @@ #include #include -#include +#include #include @@ -19,11 +19,11 @@ extern "C" namespace toucan { - class App : public dtk::IApp + class App : public feather_tk::IApp { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, std::vector&); App(); @@ -32,7 +32,7 @@ namespace toucan ~App(); static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, std::vector&); void run() override; diff --git a/bin/toucan-render/main.cpp b/bin/toucan-render/main.cpp index d34dd89..9296afc 100644 --- a/bin/toucan-render/main.cpp +++ b/bin/toucan-render/main.cpp @@ -3,8 +3,7 @@ #include "App.h" -#include -#include +#include #include @@ -20,8 +19,7 @@ int main(int argc, char** argv) } try { - auto context = dtk::Context::create(); - dtk::coreInit(context); + auto context = feather_tk::Context::create(); auto app = App::create(context, args); app->run(); out = app->getExit(); diff --git a/bin/toucan-view/main.cpp b/bin/toucan-view/main.cpp index 18c0dc1..9e81af3 100644 --- a/bin/toucan-view/main.cpp +++ b/bin/toucan-view/main.cpp @@ -3,16 +3,16 @@ #include "toucanView/App.h" -#include +#include #include -DTK_MAIN() +FEATHER_TK_MAIN() { try { - auto context = dtk::Context::create(); - auto args = dtk::convert(argc, argv); + auto context = feather_tk::Context::create(); + auto args = feather_tk::convert(argc, argv); auto app = toucan::App::create(context, args); if (app->getExit() != 0) return app->getExit(); diff --git a/cmake/SuperBuild/BuildFFmpeg.cmake b/cmake/SuperBuild/BuildFFmpeg.cmake index 072afee..d0c66bc 100644 --- a/cmake/SuperBuild/BuildFFmpeg.cmake +++ b/cmake/SuperBuild/BuildFFmpeg.cmake @@ -418,4 +418,5 @@ ExternalProject_Add( CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/lib/pkgconfig ${FFmpeg_CONFIGURE} BUILD_COMMAND ${FFmpeg_BUILD} INSTALL_COMMAND ${FFmpeg_INSTALL} - BUILD_IN_SOURCE 1) + BUILD_IN_SOURCE ON + DOWNLOAD_EXTRACT_TIMESTAMP ON) diff --git a/cmake/SuperBuild/BuildOpenTimelineIO.cmake b/cmake/SuperBuild/BuildOpenTimelineIO.cmake index 2663ef8..1d5ffeb 100644 --- a/cmake/SuperBuild/BuildOpenTimelineIO.cmake +++ b/cmake/SuperBuild/BuildOpenTimelineIO.cmake @@ -1,7 +1,7 @@ include(ExternalProject) set(OpenTimelineIO_GIT_REPOSITORY "https://github.com/AcademySoftwareFoundation/OpenTimelineIO.git") -set(OpenTimelineIO_GIT_TAG "v0.17.0") +set(OpenTimelineIO_GIT_TAG "7c58de1a19d7cdb16f08019bd504105bec4a5aa5") set(OpenTimelineIO_ARGS ${toucan_EXTERNAL_PROJECT_ARGS} diff --git a/cmake/SuperBuild/Builddtk-deps.cmake b/cmake/SuperBuild/Builddtk-deps.cmake deleted file mode 100644 index d54bf50..0000000 --- a/cmake/SuperBuild/Builddtk-deps.cmake +++ /dev/null @@ -1,23 +0,0 @@ -include(ExternalProject) - -set(dtk_GIT_REPOSITORY "https://github.com/darbyjohnston/dtk.git") -set(dtk_GIT_TAG "a18ba0cfedd430bda999a9957ce94e1dee3bd039") - -set(dtk-deps_ARGS - ${toucan_EXTERNAL_PROJECT_ARGS} - -Ddtk_UI_LIB=${toucan_dtk_UI_LIB} - -Ddtk_ZLIB=OFF - -Ddtk_PNG=OFF - -Ddtk_Freetype=OFF - -Ddtk_DEPS_ONLY=ON) - -ExternalProject_Add( - dtk-deps - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/dtk-deps - DEPENDS ZLIB PNG Freetype - GIT_REPOSITORY ${dtk_GIT_REPOSITORY} - GIT_TAG ${dtk_GIT_TAG} - SOURCE_SUBDIR etc/SuperBuild - INSTALL_COMMAND "" - LIST_SEPARATOR | - CMAKE_ARGS ${dtk-deps_ARGS}) diff --git a/cmake/SuperBuild/Builddtk.cmake b/cmake/SuperBuild/Builddtk.cmake deleted file mode 100644 index 7af9020..0000000 --- a/cmake/SuperBuild/Builddtk.cmake +++ /dev/null @@ -1,21 +0,0 @@ -include(ExternalProject) - -set(dtk_GIT_REPOSITORY "https://github.com/darbyjohnston/dtk.git") -set(dtk_GIT_TAG "a18ba0cfedd430bda999a9957ce94e1dee3bd039") - -set(dtk_DEPS dtk-deps) -set(dtk_ARGS - ${toucan_EXTERNAL_PROJECT_ARGS} - -Ddtk_UI_LIB=${toucan_dtk_UI_LIB} - -Ddtk_PYTHON=OFF - -Ddtk_TESTS=OFF - -Ddtk_EXAMPLES=OFF) - -ExternalProject_Add( - dtk - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/dtk - DEPENDS ${dtk_DEPS} - GIT_REPOSITORY ${dtk_GIT_REPOSITORY} - GIT_TAG ${dtk_GIT_TAG} - LIST_SEPARATOR | - CMAKE_ARGS ${dtk_ARGS}) diff --git a/cmake/SuperBuild/Buildfeather-tk.cmake b/cmake/SuperBuild/Buildfeather-tk.cmake new file mode 100644 index 0000000..9cbadc7 --- /dev/null +++ b/cmake/SuperBuild/Buildfeather-tk.cmake @@ -0,0 +1,25 @@ +include(ExternalProject) + +set(feather_tk_GIT_REPOSITORY "https://github.com/darbyjohnston/feather-tk.git") +set(feather_tk_GIT_TAG "f8103df2aa07a3722930c19ee9093817dd1af0c8") + +set(feather_tk_DEPS ZLIB nlohmann_json PNG Freetype lunasvg glfw3) +if(toucan_nfd) + list(APPEND feather_tk_DEPS nfd) +endif() + +set(feather_tk_ARGS + ${toucan_EXTERNAL_PROJECT_ARGS} + -Dfeather_tk_UI_LIB=ON + -Dfeather_tk_PYTHON=OFF + -Dfeather_tk_TESTS=OFF + -Dfeather_tk_EXAMPLES=OFF) + +ExternalProject_Add( + feather_tk + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/feather_tk + DEPENDS ${feather_tk_DEPS} + GIT_REPOSITORY ${feather_tk_GIT_REPOSITORY} + GIT_TAG ${feather_tk_GIT_TAG} + LIST_SEPARATOR | + CMAKE_ARGS ${feather_tk_ARGS}) diff --git a/cmake/SuperBuild/Buildglfw3.cmake b/cmake/SuperBuild/Buildglfw3.cmake new file mode 100644 index 0000000..a9a9c87 --- /dev/null +++ b/cmake/SuperBuild/Buildglfw3.cmake @@ -0,0 +1,21 @@ +include(ExternalProject) + +set(glfw3_GIT_REPOSITORY "https://github.com/glfw/glfw.git") +set(glfw3_GIT_TAG "3.4") + +set(glfw3_ARGS + ${toucan_EXTERNAL_PROJECT_ARGS} + -DCMAKE_INSTALL_LIBDIR=lib + -DGLFW_SHARED_LIBS=${BUILD_SHARED_LIBS} + -DGLFW_BUILD_EXAMPLES=FALSE + -DGLFW_BUILD_TESTS=FALSE + -DGLFW_BUILD_DOCS=FALSE + -DGLFW_BUILD_WAYLAND=OFF) + +ExternalProject_Add( + glfw3 + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glfw3 + GIT_REPOSITORY ${glfw3_GIT_REPOSITORY} + GIT_TAG ${glfw3_GIT_TAG} + LIST_SEPARATOR | + CMAKE_ARGS ${glfw3_ARGS}) diff --git a/cmake/SuperBuild/Buildlunasvg.cmake b/cmake/SuperBuild/Buildlunasvg.cmake new file mode 100644 index 0000000..111aac7 --- /dev/null +++ b/cmake/SuperBuild/Buildlunasvg.cmake @@ -0,0 +1,17 @@ +include(ExternalProject) +include(ExternalProject) + +set(lunasvg_GIT_REPOSITORY "https://github.com/sammycage/lunasvg.git") +set(lunasvg_GIT_TAG "v3.2.1") + +set(lunasvg_ARGS + ${toucan_EXTERNAL_PROJECT_ARGS} + -DLUNASVG_BUILD_EXAMPLES=OFF) + +ExternalProject_Add( + lunasvg + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/lunasvg + GIT_REPOSITORY ${lunasvg_GIT_REPOSITORY} + GIT_TAG ${lunasvg_GIT_TAG} + LIST_SEPARATOR | + CMAKE_ARGS ${lunasvg_ARGS}) diff --git a/cmake/SuperBuild/Buildnfd.cmake b/cmake/SuperBuild/Buildnfd.cmake new file mode 100644 index 0000000..53ac7cd --- /dev/null +++ b/cmake/SuperBuild/Buildnfd.cmake @@ -0,0 +1,17 @@ +include(ExternalProject) + +set(nfd_GIT_REPOSITORY "https://github.com/btzy/nativefiledialog-extended.git") +set(nfd_GIT_TAG "v1.2.1") + +set(nfd_ARGS + ${toucan_EXTERNAL_PROJECT_ARGS} + -DNFD_USE_ALLOWEDCONTENTTYPES_IF_AVAILABLE=OFF + -DNFD_BUILD_TESTS=OFF) + +ExternalProject_Add( + nfd + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/nfd + GIT_REPOSITORY ${nfd_GIT_REPOSITORY} + GIT_TAG ${nfd_GIT_TAG} + LIST_SEPARATOR | + CMAKE_ARGS ${nfd_ARGS}) diff --git a/cmake/SuperBuild/Buildnlohmann_json.cmake b/cmake/SuperBuild/Buildnlohmann_json.cmake new file mode 100644 index 0000000..47b19e9 --- /dev/null +++ b/cmake/SuperBuild/Buildnlohmann_json.cmake @@ -0,0 +1,15 @@ +include(ExternalProject) + +set(nlohmann_json_GIT_REPOSITORY "https://github.com/nlohmann/json.git") +set(nlohmann_json_GIT_TAG "v3.11.3") + +set(nlohmann_json_ARGS ${toucan_EXTERNAL_PROJECT_ARGS}) +list(APPEND nlohmann_json_ARGS -DJSON_BuildTests=OFF) + +ExternalProject_Add( + nlohmann_json + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/nlohmann_json + GIT_REPOSITORY ${nlohmann_json_GIT_REPOSITORY} + GIT_TAG ${nlohmann_json_GIT_TAG} + LIST_SEPARATOR | + CMAKE_ARGS ${nlohmann_json_ARGS}) diff --git a/cmake/SuperBuild/CMakeLists.txt b/cmake/SuperBuild/CMakeLists.txt index 93f7d44..f44f0d4 100644 --- a/cmake/SuperBuild/CMakeLists.txt +++ b/cmake/SuperBuild/CMakeLists.txt @@ -8,26 +8,30 @@ project( LANGUAGES CXX C) set(toucan_ZLIB ON CACHE BOOL "Build ZLIB") +set(toucan_minizip-ng ON CACHE BOOL "Build minizip-ng") +set(toucan_nlohmann_json ON CACHE BOOL "Build nlohmann_json") set(toucan_Freetype ON CACHE BOOL "Build Freetype") +set(toucan_lunasvg ON CACHE BOOL "Build lunasvg") set(toucan_PNG ON CACHE BOOL "Build PNG") set(toucan_NASM ON CACHE BOOL "Build NASM") set(toucan_JPEG ON CACHE BOOL "Build JPEG") set(toucan_TIFF ON CACHE BOOL "Build TIFF") set(toucan_Imath ON CACHE BOOL "Build Imath") set(toucan_OpenEXR ON CACHE BOOL "Build OpenEXR") -set(toucan_svt-av1_DEFAULT OFF) -if(NOT WIN32 AND NOT APPLE) - set(toucan_svt-av1_DEFAULT ON) -endif() -set(toucan_svt-av1 ${toucan_svt-av1_DEFAULT} CACHE BOOL "Build SVT-AV1") +set(toucan_svt-av1 OFF CACHE BOOL "Build SVT-AV1") set(toucan_FFmpeg ON CACHE BOOL "Build FFmpeg") set(toucan_FFmpeg_MINIMAL ON CACHE BOOL "Build a minimal set of FFmpeg codecs") set(toucan_OpenColorIO ON CACHE BOOL "Build OpenColorIO") set(toucan_OpenImageIO ON CACHE BOOL "Build OpenImageIO") set(toucan_OpenTimelineIO ON CACHE BOOL "Build OpenTimelineIO") set(toucan_OpenFX ON CACHE BOOL "Build OpenFX") -set(toucan_dtk ON CACHE BOOL "Build dtk") -set(toucan_dtk_UI_LIB ON CACHE BOOL "Build dtk user interface library") +set(toucan_glfw3 ON CACHE BOOL "Build glfw3") +set(toucan_nfd_default OFF) +if(WIN32 OR APPLE) + set(toucan_nfd_default ON) +endif() +set(toucan_nfd ${toucan_nfd_default} CACHE BOOL "Build native file dialog") +set(toucan_feather-tk ON CACHE BOOL "Build feather-tk") list(PREPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) @@ -70,9 +74,18 @@ set(toucan_EXTERNAL_PROJECT_ARGS if(toucan_ZLIB) include(BuildZLIB) endif() +if(toucan_minizip-ng) + include(Buildminizip-ng) +endif() +if(toucan_nlohmann_json) + include(Buildnlohmann_json) +endif() if(toucan_Freetype) include(BuildFreetype) endif() +if(toucan_lunasvg) + include(Buildlunasvg) +endif() if(toucan_PNG) include(BuildPNG) endif() @@ -99,7 +112,6 @@ if(toucan_FFmpeg) endif() if(toucan_OpenColorIO) include(Buildexpat) - include(Buildminizip-ng) include(Buildpystring) include(Buildyaml-cpp) include(BuildOpenColorIO) @@ -113,7 +125,12 @@ endif() if(toucan_OpenFX) include(BuildOpenFX) endif() -if(toucan_dtk) - include(Builddtk-deps) - include(Builddtk) +if(toucan_glfw3) + include(Buildglfw3) +endif() +if(toucan_nfd) + include(Buildnfd) +endif() +if(toucan_feather-tk) + include(Buildfeather-tk) endif() diff --git a/lib/toucanRender/CMakeLists.txt b/lib/toucanRender/CMakeLists.txt index 21f5191..610abc7 100644 --- a/lib/toucanRender/CMakeLists.txt +++ b/lib/toucanRender/CMakeLists.txt @@ -15,8 +15,7 @@ set(HEADERS TimelineAlgo.h TimelineWrapper.h Util.h) -set(HEADERS_PRIVATE - ImageEffect_p.h) +set(HEADERS_PRIVATE) set(SOURCE Comp.cpp FFmpeg.cpp @@ -45,7 +44,12 @@ else() endif() add_library(toucanRender ${HEADERS} ${HEADERS_PRIVATE} ${SOURCE}) -set(LIBS_PUBLIC dtk::dtkCore OTIO::opentimelineio OTIO::opentime OpenImageIO::OpenImageIO MINIZIP::minizip) +set(LIBS_PUBLIC + feather-tk::feather-tk-core + OTIO::opentimelineio + OTIO::opentime + OpenImageIO::OpenImageIO + MINIZIP::minizip) if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9) list(APPEND LIBS_PUBLIC stdc++fs) endif() diff --git a/lib/toucanRender/FFmpegRead.cpp b/lib/toucanRender/FFmpegRead.cpp index ce843af..da5eec4 100644 --- a/lib/toucanRender/FFmpegRead.cpp +++ b/lib/toucanRender/FFmpegRead.cpp @@ -3,7 +3,7 @@ #include "FFmpegRead.h" -#include +#include #include #include @@ -146,7 +146,7 @@ namespace toucan tag, AV_DICT_IGNORE_SUFFIX))) { - if ("timecode" == dtk::toLower(tag->key)) + if ("timecode" == feather_tk::toLower(tag->key)) { timecode = tag->value; break; @@ -296,7 +296,7 @@ namespace toucan { const std::string key(tag->key); const std::string value(tag->value); - if ("timecode" == dtk::toLower(key)) + if ("timecode" == feather_tk::toLower(key)) { timecode = value; } diff --git a/lib/toucanRender/FFmpegWrite.cpp b/lib/toucanRender/FFmpegWrite.cpp index c3d3b76..fe02b12 100644 --- a/lib/toucanRender/FFmpegWrite.cpp +++ b/lib/toucanRender/FFmpegWrite.cpp @@ -5,7 +5,7 @@ #include -#include +#include #include #include @@ -67,7 +67,7 @@ namespace toucan _avCodecContext->height = spec.height; _avCodecContext->sample_aspect_ratio = AVRational({ 1, 1 }); _avCodecContext->pix_fmt = avCodec->pix_fmts[0]; - const auto rational = dtk::toRational(timeRange.duration().rate()); + const auto rational = feather_tk::toRational(timeRange.duration().rate()); _avCodecContext->time_base = { rational.second, rational.first }; _avCodecContext->framerate = { rational.first, rational.second }; _avCodecContext->profile = avProfile; @@ -291,7 +291,7 @@ namespace toucan _avFrame->data, _avFrame->linesize); - const auto timeRational = dtk::toRational(time.rate()); + const auto timeRational = feather_tk::toRational(time.rate()); _avFrame->pts = av_rescale_q( (time - _timeRange.start_time()).value(), { timeRational.second, timeRational.first }, diff --git a/lib/toucanRender/ImageEffect.cpp b/lib/toucanRender/ImageEffect.cpp index 94ac7ba..6ef593b 100644 --- a/lib/toucanRender/ImageEffect.cpp +++ b/lib/toucanRender/ImageEffect.cpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright Contributors to the toucan project. -#include "ImageEffect_p.h" +#include "ImageEffect.h" #include diff --git a/lib/toucanRender/ImageEffect.h b/lib/toucanRender/ImageEffect.h index 5b09f28..ed564c6 100644 --- a/lib/toucanRender/ImageEffect.h +++ b/lib/toucanRender/ImageEffect.h @@ -14,10 +14,22 @@ namespace toucan { //! Image effect plugin. - struct ImageEffectPlugin; + struct ImageEffectPlugin + { + std::shared_ptr plugin; + OfxPlugin* ofxPlugin = nullptr; + PropertySet propSet; + std::map clipPropSets; + std::map paramTypes; + std::map paramDefs; + }; //! Image effect instance. - struct ImageEffectInstance; + struct ImageEffectInstance + { + std::map params; + std::map images; + }; //! Image effect handle. struct ImageEffectHandle diff --git a/lib/toucanRender/ImageEffectHost.cpp b/lib/toucanRender/ImageEffectHost.cpp index b59a271..f3a13bc 100644 --- a/lib/toucanRender/ImageEffectHost.cpp +++ b/lib/toucanRender/ImageEffectHost.cpp @@ -3,9 +3,9 @@ #include "ImageEffectHost.h" -#include "ImageEffect_p.h" +#include "ImageEffect.h" -#include +#include #include #include @@ -20,7 +20,7 @@ namespace toucan } ImageEffectHost::ImageEffectHost( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::vector& searchPath) : _context(context) { @@ -100,7 +100,7 @@ namespace toucan void ImageEffectHost::_pluginInit(const std::vector& searchPath) { // Find the plugins. - auto logSystem = _context.lock()->getSystem(); + auto logSystem = _context.lock()->getSystem(); logSystem->print(logPrefix, "Searching for plugins..."); std::vector pluginPaths; for (const auto& path : searchPath) diff --git a/lib/toucanRender/ImageEffectHost.h b/lib/toucanRender/ImageEffectHost.h index 2b9039c..99128ac 100644 --- a/lib/toucanRender/ImageEffectHost.h +++ b/lib/toucanRender/ImageEffectHost.h @@ -5,7 +5,7 @@ #include -#include +#include #include @@ -18,7 +18,7 @@ namespace toucan { public: ImageEffectHost( - const std::shared_ptr&, + const std::shared_ptr&, const std::vector& searchPath); ~ImageEffectHost(); @@ -44,7 +44,7 @@ namespace toucan static OfxStatus _clipGetImage(OfxImageClipHandle, OfxTime, const OfxRectD*, OfxPropertySetHandle*); static OfxStatus _clipReleaseImage(OfxPropertySetHandle); - std::weak_ptr _context; + std::weak_ptr _context; PropertySet _propSet; OfxHost _host; OfxPropertySuiteV1 _propertySuite; diff --git a/lib/toucanRender/ImageEffect_p.h b/lib/toucanRender/ImageEffect_p.h deleted file mode 100644 index 813a274..0000000 --- a/lib/toucanRender/ImageEffect_p.h +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright Contributors to the toucan project. - -#pragma once - -#include - -namespace toucan -{ - struct ImageEffectPlugin - { - std::shared_ptr plugin; - OfxPlugin* ofxPlugin = nullptr; - PropertySet propSet; - std::map clipPropSets; - std::map paramTypes; - std::map paramDefs; - }; - - struct ImageEffectInstance - { - std::map params; - std::map images; - }; -} diff --git a/lib/toucanRender/ImageGraph.cpp b/lib/toucanRender/ImageGraph.cpp index b95ca17..c89565f 100644 --- a/lib/toucanRender/ImageGraph.cpp +++ b/lib/toucanRender/ImageGraph.cpp @@ -10,7 +10,7 @@ #include "TimelineAlgo.h" #include "Util.h" -#include +#include #include #include @@ -40,7 +40,7 @@ namespace toucan } ImageGraph::ImageGraph( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::filesystem::path& path, const std::shared_ptr& timelineWrapper) : _context(context), @@ -80,10 +80,10 @@ namespace toucan } catch (const std::exception& e) { - _context.lock()->getSystem()->print( + _context.lock()->getSystem()->print( logPrefix, e.what(), - dtk::LogType::Error); + feather_tk::LogType::Error); } } else if (auto sequenceRef = dynamic_cast(clip->media_reference())) @@ -112,10 +112,10 @@ namespace toucan } catch (const std::exception& e) { - _context.lock()->getSystem()->print( + _context.lock()->getSystem()->print( logPrefix, e.what(), - dtk::LogType::Error); + feather_tk::LogType::Error); } } else if (auto generatorRef = dynamic_cast(clip->media_reference())) @@ -365,10 +365,10 @@ namespace toucan } catch (const std::exception& e) { - _context.lock()->getSystem()->print( + _context.lock()->getSystem()->print( logPrefix, e.what(), - dtk::LogType::Error); + feather_tk::LogType::Error); } _loadCache.add(externalRef, read); } @@ -408,10 +408,10 @@ namespace toucan } catch (const std::exception& e) { - _context.lock()->getSystem()->print( + _context.lock()->getSystem()->print( logPrefix, e.what(), - dtk::LogType::Error); + feather_tk::LogType::Error); } if (read) { diff --git a/lib/toucanRender/ImageGraph.h b/lib/toucanRender/ImageGraph.h index ff8570d..ebbe7b8 100644 --- a/lib/toucanRender/ImageGraph.h +++ b/lib/toucanRender/ImageGraph.h @@ -6,8 +6,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -25,7 +25,7 @@ namespace toucan { public: ImageGraph( - const std::shared_ptr&, + const std::shared_ptr&, const std::filesystem::path&, const std::shared_ptr&); @@ -63,13 +63,13 @@ namespace toucan const std::vector >&, const std::shared_ptr&); - std::weak_ptr _context; + std::weak_ptr _context; std::filesystem::path _path; std::shared_ptr _timelineWrapper; OTIO_NS::TimeRange _timeRange; IMATH_NAMESPACE::V2i _imageSize = IMATH_NAMESPACE::V2i(0, 0); int _imageChannels = 0; std::string _imageDataType; - dtk::LRUCache > _loadCache; + feather_tk::LRUCache > _loadCache; }; } diff --git a/lib/toucanRender/TimelineWrapper.cpp b/lib/toucanRender/TimelineWrapper.cpp index 837bd9c..fc9b84f 100644 --- a/lib/toucanRender/TimelineWrapper.cpp +++ b/lib/toucanRender/TimelineWrapper.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include @@ -69,7 +69,7 @@ namespace toucan TimelineWrapper::TimelineWrapper(const std::filesystem::path& path) : _path(path) { - const std::string extension = dtk::toLower(_path.extension().string()); + const std::string extension = feather_tk::toLower(_path.extension().string()); if (".otio" == extension) { OTIO_NS::ErrorStatus errorStatus; diff --git a/lib/toucanView/App.cpp b/lib/toucanView/App.cpp index 6ed73f4..97f271e 100644 --- a/lib/toucanView/App.cpp +++ b/lib/toucanView/App.cpp @@ -11,52 +11,52 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include #include namespace toucan { void App::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, std::vector& argv) { - dtk::App::_init( + feather_tk::App::_init( context, argv, "toucan-view", "Toucan viewer", { - dtk::CmdLineValueArg::create( + feather_tk::CmdLineValueArg::create( _path, "input", "Input timeline.", true) - }, - {}, - dtk::getSettingsPath("toucan", "toucan-view.settings").string()); - - _timeUnitsModel = std::make_shared(context); + }); + + _settings = feather_tk::Settings::create(context, feather_tk::getSettingsPath("toucan", "toucan-view.settings")); + + _timeUnitsModel = std::make_shared(context, _settings); _host = std::make_shared(context, getOpenFXPluginPaths(getExeName())); - auto fileBrowserSystem = context->getSystem(); + auto fileBrowserSystem = context->getSystem(); fileBrowserSystem->setNativeFileDialog(false); - _filesModel = std::make_shared(context, _host); - _globalViewModel = std::make_shared(context); - _windowModel = std::make_shared(context); + _filesModel = std::make_shared(context, _settings, _host); + _globalViewModel = std::make_shared(context, _settings); + _windowModel = std::make_shared(context, _settings); _window = MainWindow::create( context, std::dynamic_pointer_cast(shared_from_this()), "toucan-view", - dtk::Size2I(1920, 1080)); + feather_tk::Size2I(1920, 1080)); addWindow(_window); _window->show(); @@ -70,7 +70,7 @@ namespace toucan {} std::shared_ptr App::create( - const std::shared_ptr& context, + const std::shared_ptr& context, std::vector& argv) { auto out = std::shared_ptr(new App); @@ -78,6 +78,11 @@ namespace toucan return out; } + const std::shared_ptr& App::getSettings() const + { + return _settings; + } + const std::shared_ptr& App::getTimeUnitsModel() const { return _timeUnitsModel; @@ -111,7 +116,7 @@ namespace toucan } catch (const std::exception& e) { - _context->getSystem()->message( + _context->getSystem()->message( "ERROR", e.what(), _window); diff --git a/lib/toucanView/App.h b/lib/toucanView/App.h index 4053181..da3728e 100644 --- a/lib/toucanView/App.h +++ b/lib/toucanView/App.h @@ -3,7 +3,8 @@ #pragma once -#include +#include +#include #include @@ -17,11 +18,11 @@ namespace toucan class WindowModel; //! Application. - class App : public dtk::App + class App : public feather_tk::App { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, std::vector&); public: @@ -29,9 +30,12 @@ namespace toucan //! Create a new application. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, std::vector&); + //! Get the settings. + const std::shared_ptr& getSettings() const; + //! Get the time units model. const std::shared_ptr& getTimeUnitsModel() const; @@ -52,6 +56,7 @@ namespace toucan private: std::string _path; + std::shared_ptr _settings; std::shared_ptr _timeUnitsModel; std::shared_ptr _host; std::shared_ptr _filesModel; diff --git a/lib/toucanView/AudioClipItem.cpp b/lib/toucanView/AudioClipItem.cpp index 95eaa33..48c2cd4 100644 --- a/lib/toucanView/AudioClipItem.cpp +++ b/lib/toucanView/AudioClipItem.cpp @@ -8,18 +8,18 @@ #include -#include +#include #include namespace toucan { void AudioClipItem::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& clip, const OTIO_NS::SerializableObject::Retainer& timeline, - const dtk::Color4F& color, + const feather_tk::Color4F& color, const std::shared_ptr& parent) { OTIO_NS::TimeRange timeRange = clip->transformed_time_range( @@ -48,8 +48,8 @@ namespace toucan setTooltip(clip->schema_name() + ": " + _text); - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingTool); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingTool); _label = ItemLabel::create(context, _layout); _label->setName(_text); @@ -88,11 +88,11 @@ namespace toucan {} std::shared_ptr AudioClipItem::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& clip, const OTIO_NS::SerializableObject::Retainer& timeline, - const dtk::Color4F& color, + const feather_tk::Color4F& color, const std::shared_ptr& parent) { auto out = std::make_shared(); @@ -109,21 +109,21 @@ namespace toucan } } - void AudioClipItem::setGeometry(const dtk::Box2I& value) + void AudioClipItem::setGeometry(const feather_tk::Box2I& value) { IItem::setGeometry(value); _layout->setGeometry(value); - _geom.g2 = dtk::margin(value, -_size.border, 0, -_size.border, 0); - _geom.g3 = dtk::margin(_label->getGeometry(), -_size.border, 0, -_size.border, 0); + _geom.g2 = feather_tk::margin(value, -_size.border, 0, -_size.border, 0); + _geom.g3 = feather_tk::margin(_label->getGeometry(), -_size.border, 0, -_size.border, 0); _selectionRect = _geom.g3; } - dtk::Box2I AudioClipItem::getChildrenClipRect() const + feather_tk::Box2I AudioClipItem::getChildrenClipRect() const { return _geom.g2; } - void AudioClipItem::sizeHintEvent(const dtk::SizeHintEvent& event) + void AudioClipItem::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IItem::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -131,19 +131,19 @@ namespace toucan { _size.init = false; _size.displayScale = event.displayScale; - _size.border = event.style->getSizeRole(dtk::SizeRole::Border, event.displayScale); + _size.border = event.style->getSizeRole(feather_tk::SizeRole::Border, event.displayScale); } _setSizeHint(_layout->getSizeHint()); } void AudioClipItem::drawEvent( - const dtk::Box2I& drawRect, - const dtk::DrawEvent& event) + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent& event) { IItem::drawEvent(drawRect, event); event.render->drawRect( _geom.g3, - _selected ? event.style->getColorRole(dtk::ColorRole::Yellow) : _color); + _selected ? event.style->getColorRole(feather_tk::ColorRole::Yellow) : _color); } void AudioClipItem::_timeUnitsUpdate() @@ -151,11 +151,11 @@ namespace toucan _textUpdate(); } - void AudioClipItem::_buildMenu(const std::shared_ptr& menu) + void AudioClipItem::_buildMenu(const std::shared_ptr& menu) { if (auto externalReference = dynamic_cast(_clip->media_reference())) { - auto action = std::make_shared( + auto action = feather_tk::Action::create( "Open Media", [this, externalReference] { @@ -164,7 +164,7 @@ namespace toucan auto app = _app.lock(); app->open(path); }); - menu->addItem(action); + menu->addAction(action); menu->addDivider(); } IItem::_buildMenu(menu); diff --git a/lib/toucanView/AudioClipItem.h b/lib/toucanView/AudioClipItem.h index 8aeac71..9b518a6 100644 --- a/lib/toucanView/AudioClipItem.h +++ b/lib/toucanView/AudioClipItem.h @@ -7,7 +7,7 @@ #include #include -#include +#include #include @@ -18,11 +18,11 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::SerializableObject::Retainer&, - const dtk::Color4F&, + const feather_tk::Color4F&, const std::shared_ptr& parent); public: @@ -30,32 +30,32 @@ namespace toucan //! Create a new item. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::SerializableObject::Retainer&, - const dtk::Color4F&, + const feather_tk::Color4F&, const std::shared_ptr& parent = nullptr); void setScale(double) override; - void setGeometry(const dtk::Box2I&) override; - dtk::Box2I getChildrenClipRect() const override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + feather_tk::Box2I getChildrenClipRect() const override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; protected: void _timeUnitsUpdate() override; - void _buildMenu(const std::shared_ptr&) override; + void _buildMenu(const std::shared_ptr&) override; private: void _textUpdate(); OTIO_NS::SerializableObject::Retainer _clip; std::string _text; - dtk::Color4F _color; + feather_tk::Color4F _color; - std::shared_ptr _layout; + std::shared_ptr _layout; std::shared_ptr _label; std::shared_ptr _markerLayout; std::vector > _markerItems; @@ -70,8 +70,8 @@ namespace toucan struct GeomData { - dtk::Box2I g2; - dtk::Box2I g3; + feather_tk::Box2I g2; + feather_tk::Box2I g3; }; GeomData _geom; }; diff --git a/lib/toucanView/BackgroundTool.cpp b/lib/toucanView/BackgroundTool.cpp index e54511d..48acf8b 100644 --- a/lib/toucanView/BackgroundTool.cpp +++ b/lib/toucanView/BackgroundTool.cpp @@ -5,42 +5,42 @@ #include "App.h" -#include -#include -#include -#include +#include +#include +#include +#include namespace toucan { void BackgroundTool::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IToolWidget::_init(context, app, "toucan::BackgroundTool", "Background", parent); _model = app->getGlobalViewModel(); - _scrollWidget = dtk::ScrollWidget::create(context, dtk::ScrollType::Both, shared_from_this()); + _scrollWidget = feather_tk::ScrollWidget::create(context, feather_tk::ScrollType::Both, shared_from_this()); _scrollWidget->setBorder(false); - _layout = dtk::VerticalLayout::create(context); - _layout->setMarginRole(dtk::SizeRole::MarginSmall); - _layout->setSpacingRole(dtk::SizeRole::SpacingSmall); + _layout = feather_tk::VerticalLayout::create(context); + _layout->setMarginRole(feather_tk::SizeRole::MarginSmall); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); _scrollWidget->setWidget(_layout); - _comboBox = dtk::ComboBox::create(context, getViewBackgroundLabels(), _layout); + _comboBox = feather_tk::ComboBox::create(context, getViewBackgroundLabels(), _layout); - dtk::Divider::create(context, dtk::Orientation::Vertical, _layout); + feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, _layout); - _solidColorWidget = dtk::ColorWidget::create(context, _layout); + _solidColorWidget = feather_tk::ColorWidget::create(context, _layout); - _checkersColor0Widget = dtk::ColorWidget::create(context, _layout); + _checkersColor0Widget = feather_tk::ColorWidget::create(context, _layout); - _checkersColor1Widget = dtk::ColorWidget::create(context, _layout); + _checkersColor1Widget = feather_tk::ColorWidget::create(context, _layout); - _checkersSizeSlider = dtk::IntEditSlider::create(context, _layout); - _checkersSizeSlider->setRange(dtk::RangeI(10, 100)); + _checkersSizeSlider = feather_tk::IntEditSlider::create(context, _layout); + _checkersSizeSlider->setRange(feather_tk::RangeI(10, 100)); _comboBox->setIndexCallback( [this](int value) @@ -54,7 +54,7 @@ namespace toucan }); _solidColorWidget->setCallback( - [this](const dtk::Color4F& value) + [this](const feather_tk::Color4F& value) { if (_model) { @@ -65,7 +65,7 @@ namespace toucan }); _checkersColor0Widget->setCallback( - [this](const dtk::Color4F& value) + [this](const feather_tk::Color4F& value) { if (_model) { @@ -76,7 +76,7 @@ namespace toucan }); _checkersColor1Widget->setCallback( - [this](const dtk::Color4F& value) + [this](const feather_tk::Color4F& value) { if (_model) { @@ -97,7 +97,7 @@ namespace toucan } }); - _optionsObserver = dtk::ValueObserver::create( + _optionsObserver = feather_tk::ValueObserver::create( _model->observeOptions(), [this](const GlobalViewOptions& value) { @@ -110,22 +110,22 @@ namespace toucan {} std::shared_ptr BackgroundTool::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new BackgroundTool); out->_init(context, app, parent); return out; } - void BackgroundTool::setGeometry(const dtk::Box2I& value) + void BackgroundTool::setGeometry(const feather_tk::Box2I& value) { IToolWidget::setGeometry(value); _scrollWidget->setGeometry(value); } - void BackgroundTool::sizeHintEvent(const dtk::SizeHintEvent& event) + void BackgroundTool::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IToolWidget::sizeHintEvent(event); _setSizeHint(_scrollWidget->getSizeHint()); diff --git a/lib/toucanView/BackgroundTool.h b/lib/toucanView/BackgroundTool.h index 0eb6aae..4b9739d 100644 --- a/lib/toucanView/BackgroundTool.h +++ b/lib/toucanView/BackgroundTool.h @@ -7,11 +7,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace toucan { @@ -22,7 +22,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -31,12 +31,12 @@ namespace toucan //! Create a new tool. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: void _widgetUpdate(); @@ -44,15 +44,15 @@ namespace toucan std::shared_ptr _model; GlobalViewOptions _options; - std::shared_ptr _scrollWidget; - std::shared_ptr _layout; - std::shared_ptr _comboBox; - std::shared_ptr _solidColorWidget; - std::shared_ptr _checkersColor0Widget; - std::shared_ptr _checkersColor1Widget; - std::shared_ptr _checkersSizeSlider; + std::shared_ptr _scrollWidget; + std::shared_ptr _layout; + std::shared_ptr _comboBox; + std::shared_ptr _solidColorWidget; + std::shared_ptr _checkersColor0Widget; + std::shared_ptr _checkersColor1Widget; + std::shared_ptr _checkersSizeSlider; - std::shared_ptr > _optionsObserver; + std::shared_ptr > _optionsObserver; }; } diff --git a/lib/toucanView/CMakeLists.txt b/lib/toucanView/CMakeLists.txt index dc54cab..86825b8 100644 --- a/lib/toucanView/CMakeLists.txt +++ b/lib/toucanView/CMakeLists.txt @@ -99,6 +99,6 @@ set(SOURCE WindowToolBar.cpp) add_library(toucanView ${HEADERS} ${SOURCE}) -target_link_libraries(toucanView PUBLIC toucanRender dtk::dtkUI) +target_link_libraries(toucanView PUBLIC toucanRender feather-tk::feather-tk-ui) set_target_properties(toucanView PROPERTIES FOLDER lib) add_dependencies(toucanView ${TOUCAN_PLUGINS}) diff --git a/lib/toucanView/CompareMenu.cpp b/lib/toucanView/CompareMenu.cpp index e8b6953..c7eb78f 100644 --- a/lib/toucanView/CompareMenu.cpp +++ b/lib/toucanView/CompareMenu.cpp @@ -5,16 +5,16 @@ #include "App.h" -#include +#include namespace toucan { void CompareMenu::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::Menu::_init(context, parent); + feather_tk::Menu::_init(context, parent); _filesModel = app->getFilesModel(); @@ -22,91 +22,91 @@ namespace toucan addDivider(); - _actions["Compare/A"] = std::make_shared( + _actions["Compare/A"] = feather_tk::Action::create( "A", - dtk::Key::A, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::A, + static_cast(feather_tk::KeyModifier::Shift), [this](bool) { CompareOptions options = _filesModel->getCompareOptions(); options.mode = CompareMode::A; _filesModel->setCompareOptions(options); }); - addItem(_actions["Compare/A"]); + addAction(_actions["Compare/A"]); - _actions["Compare/B"] = std::make_shared( + _actions["Compare/B"] = feather_tk::Action::create( "B", - dtk::Key::B, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::B, + static_cast(feather_tk::KeyModifier::Shift), [this](bool) { CompareOptions options = _filesModel->getCompareOptions(); options.mode = CompareMode::B; _filesModel->setCompareOptions(options); }); - addItem(_actions["Compare/B"]); + addAction(_actions["Compare/B"]); - _actions["Compare/Split"] = std::make_shared( + _actions["Compare/Split"] = feather_tk::Action::create( "Split", - dtk::Key::S, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::S, + static_cast(feather_tk::KeyModifier::Shift), [this](bool) { CompareOptions options = _filesModel->getCompareOptions(); options.mode = CompareMode::Split; _filesModel->setCompareOptions(options); }); - addItem(_actions["Compare/Split"]); + addAction(_actions["Compare/Split"]); - _actions["Compare/Overlay"] = std::make_shared( + _actions["Compare/Overlay"] = feather_tk::Action::create( "Overlay", - dtk::Key::E, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::E, + static_cast(feather_tk::KeyModifier::Shift), [this](bool) { CompareOptions options = _filesModel->getCompareOptions(); options.mode = CompareMode::Overlay; _filesModel->setCompareOptions(options); }); - addItem(_actions["Compare/Overlay"]); + addAction(_actions["Compare/Overlay"]); - _actions["Compare/Horizontal"] = std::make_shared( + _actions["Compare/Horizontal"] = feather_tk::Action::create( "Horizontal", - dtk::Key::H, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::H, + static_cast(feather_tk::KeyModifier::Shift), [this](bool) { CompareOptions options = _filesModel->getCompareOptions(); options.mode = CompareMode::Horizontal; _filesModel->setCompareOptions(options); }); - addItem(_actions["Compare/Horizontal"]); + addAction(_actions["Compare/Horizontal"]); - _actions["Compare/Vertical"] = std::make_shared( + _actions["Compare/Vertical"] = feather_tk::Action::create( "Vertical", - dtk::Key::V, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::V, + static_cast(feather_tk::KeyModifier::Shift), [this](bool) { CompareOptions options = _filesModel->getCompareOptions(); options.mode = CompareMode::Vertical; _filesModel->setCompareOptions(options); }); - addItem(_actions["Compare/Vertical"]); + addAction(_actions["Compare/Vertical"]); - _modeObserver = dtk::ValueObserver::create( + _modeObserver = feather_tk::ValueObserver::create( app->getFilesModel()->observeCompareOptions(), [this](const CompareOptions& value) { - setItemChecked(_actions["Compare/A"], CompareMode::A == value.mode); - setItemChecked(_actions["Compare/B"], CompareMode::B == value.mode); - setItemChecked(_actions["Compare/Split"], CompareMode::Split == value.mode); - setItemChecked(_actions["Compare/Overlay"], CompareMode::Overlay == value.mode); - setItemChecked(_actions["Compare/Horizontal"], CompareMode::Horizontal == value.mode); - setItemChecked(_actions["Compare/Vertical"], CompareMode::Vertical == value.mode); + setChecked(_actions["Compare/A"], CompareMode::A == value.mode); + setChecked(_actions["Compare/B"], CompareMode::B == value.mode); + setChecked(_actions["Compare/Split"], CompareMode::Split == value.mode); + setChecked(_actions["Compare/Overlay"], CompareMode::Overlay == value.mode); + setChecked(_actions["Compare/Horizontal"], CompareMode::Horizontal == value.mode); + setChecked(_actions["Compare/Vertical"], CompareMode::Vertical == value.mode); }); - _filesObserver = dtk::ListObserver >::create( + _filesObserver = feather_tk::ListObserver >::create( _filesModel->observeFiles(), [this](const std::vector >& files) { @@ -114,19 +114,19 @@ namespace toucan _bFileActions.clear(); for (int i = 0; i < files.size(); ++i) { - auto item = std::make_shared( + auto action = feather_tk::Action::create( files[i]->getPath().filename().string(), [this, i](bool value) { _filesModel->setBIndex(value ? i : -1); close(); }); - _menus["BFile"]->addItem(item); - _bFileActions.push_back(item); + _menus["BFile"]->addAction(action); + _bFileActions.push_back(action); } }); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { @@ -134,13 +134,13 @@ namespace toucan _menuUpdate(); }); - _bIndexObserver = dtk::ValueObserver::create( + _bIndexObserver = feather_tk::ValueObserver::create( _filesModel->observeBIndex(), [this](int index) { for (int i = 0; i < _bFileActions.size(); ++i) { - _menus["BFile"]->setItemChecked(_bFileActions[i], i == index); + _menus["BFile"]->setChecked(_bFileActions[i], i == index); } }); } @@ -149,16 +149,16 @@ namespace toucan {} std::shared_ptr CompareMenu::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new CompareMenu); out->_init(context, app, parent); return out; } - const std::map >& CompareMenu::getActions() const + const std::map >& CompareMenu::getActions() const { return _actions; } @@ -167,11 +167,11 @@ namespace toucan { const bool file = _file.get(); setSubMenuEnabled(_menus["BFile"], file); - setItemEnabled(_actions["Compare/A"], file); - setItemEnabled(_actions["Compare/B"], file); - setItemEnabled(_actions["Compare/Split"], file); - setItemEnabled(_actions["Compare/Overlay"], file); - setItemEnabled(_actions["Compare/Horizontal"], file); - setItemEnabled(_actions["Compare/Vertical"], file); + setEnabled(_actions["Compare/A"], file); + setEnabled(_actions["Compare/B"], file); + setEnabled(_actions["Compare/Split"], file); + setEnabled(_actions["Compare/Overlay"], file); + setEnabled(_actions["Compare/Horizontal"], file); + setEnabled(_actions["Compare/Vertical"], file); } } diff --git a/lib/toucanView/CompareMenu.h b/lib/toucanView/CompareMenu.h index 4e6ce70..f0ef363 100644 --- a/lib/toucanView/CompareMenu.h +++ b/lib/toucanView/CompareMenu.h @@ -5,7 +5,7 @@ #include -#include +#include #include @@ -14,11 +14,11 @@ namespace toucan class App; //! Compare menu. - class CompareMenu : public dtk::Menu + class CompareMenu : public feather_tk::Menu { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -27,12 +27,12 @@ namespace toucan //! Create a new menu. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Get the actions. - const std::map >& getActions() const; + const std::map >& getActions() const; private: void _menuUpdate(); @@ -40,13 +40,13 @@ namespace toucan std::shared_ptr _filesModel; std::shared_ptr _file; - std::map > _menus; - std::map > _actions; - std::vector > _bFileActions; + std::map > _menus; + std::map > _actions; + std::vector > _bFileActions; - std::shared_ptr > > _filesObserver; - std::shared_ptr > > _fileObserver; - std::shared_ptr > _bIndexObserver; - std::shared_ptr > _modeObserver; + std::shared_ptr > > _filesObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > _bIndexObserver; + std::shared_ptr > _modeObserver; }; } diff --git a/lib/toucanView/CompareTool.cpp b/lib/toucanView/CompareTool.cpp index 6d386d8..4c2af7c 100644 --- a/lib/toucanView/CompareTool.cpp +++ b/lib/toucanView/CompareTool.cpp @@ -6,30 +6,30 @@ #include "App.h" #include "SelectionModel.h" -#include -#include -#include -#include +#include +#include +#include +#include namespace toucan { void CompareWidget::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& file, const std::shared_ptr& parent) { IWidget::_init(context, "toucan::CompareWidget", parent); - _layout = dtk::HorizontalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingTool); + _layout = feather_tk::HorizontalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingTool); - _button = dtk::ToolButton::create(context, _layout); + _button = feather_tk::ToolButton::create(context, _layout); std::string text = file->getPath().filename().string(); - _button->setText(dtk::elide(text)); - _button->setHStretch(dtk::Stretch::Expanding); + _button->setText(feather_tk::elide(text)); + _button->setHStretch(feather_tk::Stretch::Expanding); _button->setTooltip(text); - _bButton = dtk::ToolButton::create(context, _layout); + _bButton = feather_tk::ToolButton::create(context, _layout); _bButton->setText("B"); _bButton->setCheckable(true); _bButton->setTooltip("Set the B file for comparison"); @@ -39,7 +39,7 @@ namespace toucan {} std::shared_ptr CompareWidget::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& file, const std::shared_ptr& parent) { @@ -50,7 +50,7 @@ namespace toucan void CompareWidget::setCurrent(bool value) { - _button->setButtonRole(value ? dtk::ColorRole::Checked : dtk::ColorRole::None); + _button->setButtonRole(value ? feather_tk::ColorRole::Checked : feather_tk::ColorRole::None); } void CompareWidget::setCurrentCallback(const std::function& callback) @@ -72,62 +72,62 @@ namespace toucan _bButton->setCheckedCallback(value); } - void CompareWidget::setGeometry(const dtk::Box2I& value) + void CompareWidget::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void CompareWidget::sizeHintEvent(const dtk::SizeHintEvent& event) + void CompareWidget::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); } void CompareTool::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IToolWidget::_init(context, app, "toucan::CompareTool", "Compare", parent); _filesModel = app->getFilesModel(); - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::None); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::None); - _scrollWidget = dtk::ScrollWidget::create(context, dtk::ScrollType::Both, _layout); + _scrollWidget = feather_tk::ScrollWidget::create(context, feather_tk::ScrollType::Both, _layout); _scrollWidget->setBorder(false); - _scrollWidget->setVStretch(dtk::Stretch::Expanding); + _scrollWidget->setVStretch(feather_tk::Stretch::Expanding); - _widgetLayout = dtk::VerticalLayout::create(context); - _widgetLayout->setSpacingRole(dtk::SizeRole::SpacingTool); + _widgetLayout = feather_tk::VerticalLayout::create(context); + _widgetLayout->setSpacingRole(feather_tk::SizeRole::SpacingTool); _scrollWidget->setWidget(_widgetLayout); - dtk::Divider::create(context, dtk::Orientation::Vertical, _layout); + feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, _layout); - _bottomLayout = dtk::GridLayout::create(context, _layout); - _bottomLayout->setMarginRole(dtk::SizeRole::MarginSmall); - _bottomLayout->setSpacingRole(dtk::SizeRole::SpacingSmall); + _bottomLayout = feather_tk::GridLayout::create(context, _layout); + _bottomLayout->setMarginRole(feather_tk::SizeRole::MarginSmall); + _bottomLayout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); - auto label = dtk::Label::create(context, "Mode:", _bottomLayout); + auto label = feather_tk::Label::create(context, "Mode:", _bottomLayout); _bottomLayout->setGridPos(label, 0, 0); - _modeComboBox = dtk::ComboBox::create(context, getCompareModeLabels(), _bottomLayout); - _modeComboBox->setHStretch(dtk::Stretch::Expanding); + _modeComboBox = feather_tk::ComboBox::create(context, getCompareModeLabels(), _bottomLayout); + _modeComboBox->setHStretch(feather_tk::Stretch::Expanding); _modeComboBox->setTooltip("Set the comparison mode"); _bottomLayout->setGridPos(_modeComboBox, 0, 1); - label = dtk::Label::create(context, "Start time:", _bottomLayout); + label = feather_tk::Label::create(context, "Start time:", _bottomLayout); _bottomLayout->setGridPos(label, 1, 0); - _startTimeCheckBox = dtk::CheckBox::create(context, _bottomLayout); - _startTimeCheckBox->setHStretch(dtk::Stretch::Expanding); + _startTimeCheckBox = feather_tk::CheckBox::create(context, _bottomLayout); + _startTimeCheckBox->setHStretch(feather_tk::Stretch::Expanding); _startTimeCheckBox->setTooltip("Match the A and B start times"); _bottomLayout->setGridPos(_startTimeCheckBox, 1, 1); - label = dtk::Label::create(context, "Resize:", _bottomLayout); + label = feather_tk::Label::create(context, "Resize:", _bottomLayout); _bottomLayout->setGridPos(label, 2, 0); - _resizeCheckBox = dtk::CheckBox::create(context, _bottomLayout); - _resizeCheckBox->setHStretch(dtk::Stretch::Expanding); + _resizeCheckBox = feather_tk::CheckBox::create(context, _bottomLayout); + _resizeCheckBox->setHStretch(feather_tk::Stretch::Expanding); _resizeCheckBox->setTooltip("Resize the B image to match the A size"); _bottomLayout->setGridPos(_resizeCheckBox, 2, 1); @@ -155,7 +155,7 @@ namespace toucan _filesModel->setCompareOptions(options); }); - _filesObserver = dtk::ListObserver >::create( + _filesObserver = feather_tk::ListObserver >::create( _filesModel->observeFiles(), [this](const std::vector >& value) { @@ -164,7 +164,7 @@ namespace toucan _indexUpdate(); }); - _fileIndexObserver = dtk::ValueObserver::create( + _fileIndexObserver = feather_tk::ValueObserver::create( _filesModel->observeCurrentIndex(), [this](int value) { @@ -172,7 +172,7 @@ namespace toucan _indexUpdate(); }); - _bIndexObserver = dtk::ValueObserver::create( + _bIndexObserver = feather_tk::ValueObserver::create( _filesModel->observeBIndex(), [this](int value) { @@ -180,7 +180,7 @@ namespace toucan _indexUpdate(); }); - _compareOptionsObserver = dtk::ValueObserver::create( + _compareOptionsObserver = feather_tk::ValueObserver::create( _filesModel->observeCompareOptions(), [this](const CompareOptions& value) { @@ -194,22 +194,22 @@ namespace toucan {} std::shared_ptr CompareTool::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new CompareTool); out->_init(context, app, parent); return out; } - void CompareTool::setGeometry(const dtk::Box2I& value) + void CompareTool::setGeometry(const feather_tk::Box2I& value) { IToolWidget::setGeometry(value); _layout->setGeometry(value); } - void CompareTool::sizeHintEvent(const dtk::SizeHintEvent& event) + void CompareTool::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IToolWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); diff --git a/lib/toucanView/CompareTool.h b/lib/toucanView/CompareTool.h index 9576e9a..c15c7b6 100644 --- a/lib/toucanView/CompareTool.h +++ b/lib/toucanView/CompareTool.h @@ -6,24 +6,24 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include namespace toucan { class File; //! Compare widget. - class CompareWidget : public dtk::IWidget + class CompareWidget : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -32,7 +32,7 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); @@ -42,16 +42,16 @@ namespace toucan void setB(bool); void setBCallback(const std::function&); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: bool _current = false; bool _b = false; - std::shared_ptr _layout; - std::shared_ptr _button; - std::shared_ptr _bButton; + std::shared_ptr _layout; + std::shared_ptr _button; + std::shared_ptr _bButton; }; //! Compare tool. @@ -59,7 +59,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -68,12 +68,12 @@ namespace toucan //! Create a new tool. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: void _widgetUpdate(); @@ -84,19 +84,19 @@ namespace toucan int _currentIndex = -1; int _bIndex = -1; - std::shared_ptr _layout; - std::shared_ptr _scrollWidget; - std::shared_ptr _widgetLayout; + std::shared_ptr _layout; + std::shared_ptr _scrollWidget; + std::shared_ptr _widgetLayout; std::vector > _widgets; - std::shared_ptr _bottomLayout; - std::shared_ptr _modeComboBox; - std::shared_ptr _startTimeCheckBox; - std::shared_ptr _resizeCheckBox; - - std::shared_ptr > > _filesObserver; - std::shared_ptr > _fileIndexObserver; - std::shared_ptr > _bIndexObserver; - std::shared_ptr > _compareOptionsObserver; + std::shared_ptr _bottomLayout; + std::shared_ptr _modeComboBox; + std::shared_ptr _startTimeCheckBox; + std::shared_ptr _resizeCheckBox; + + std::shared_ptr > > _filesObserver; + std::shared_ptr > _fileIndexObserver; + std::shared_ptr > _bIndexObserver; + std::shared_ptr > _compareOptionsObserver; }; } diff --git a/lib/toucanView/DetailsTool.cpp b/lib/toucanView/DetailsTool.cpp index 657c650..10a8b3a 100644 --- a/lib/toucanView/DetailsTool.cpp +++ b/lib/toucanView/DetailsTool.cpp @@ -7,45 +7,45 @@ #include "FilesModel.h" #include "PlaybackModel.h" -#include -#include -#include -#include +#include +#include +#include +#include #include namespace toucan { void DetailsWidget::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& file, const SelectionItem& item, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IWidget::_init(context, "toucan::DetailsWidget", parent); _file = file; _item = item; - _bellows = dtk::Bellows::create(context, item.object->name(), shared_from_this()); + _bellows = feather_tk::Bellows::create(context, item.object->name(), shared_from_this()); _bellows->setOpen(true); - auto hLayout = dtk::HorizontalLayout::create(context); - hLayout->setSpacingRole(dtk::SizeRole::None); - _startFrameButton = dtk::ToolButton::create(context, hLayout); + auto hLayout = feather_tk::HorizontalLayout::create(context); + hLayout->setSpacingRole(feather_tk::SizeRole::None); + _startFrameButton = feather_tk::ToolButton::create(context, hLayout); _startFrameButton->setIcon("ArrowRight"); _startFrameButton->setTooltip("Go to the start frame"); if (item.timeRange.duration().value() > 1.0) { - _inOutButton = dtk::ToolButton::create(context, hLayout); + _inOutButton = feather_tk::ToolButton::create(context, hLayout); _inOutButton->setIcon("FrameInOut"); _inOutButton->setTooltip("Set the in/out points"); } _bellows->setToolWidget(hLayout); - _layout = dtk::GridLayout::create(context); - _layout->setRowBackgroundRole(dtk::ColorRole::Base); - _layout->setSpacingRole(dtk::SizeRole::None); + _layout = feather_tk::GridLayout::create(context); + _layout->setRowBackgroundRole(feather_tk::ColorRole::Base); + _layout->setSpacingRole(feather_tk::SizeRole::None); _bellows->setWidget(_layout); OTIO_NS::TimeRange timeRange = item.timeRange; @@ -71,7 +71,7 @@ namespace toucan }); } - _timeUnitsObserver = dtk::ValueObserver::create( + _timeUnitsObserver = feather_tk::ValueObserver::create( app->getTimeUnitsModel()->observeTimeUnits(), [this](TimeUnits value) { @@ -85,11 +85,11 @@ namespace toucan {} std::shared_ptr DetailsWidget::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& file, const SelectionItem& item, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new DetailsWidget); out->_init(context, app, file, item, parent); @@ -109,16 +109,16 @@ namespace toucan _searchUpdate(); } - void DetailsWidget::setGeometry(const dtk::Box2I& value) + void DetailsWidget::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _bellows->setGeometry(value); } - void DetailsWidget::sizeHintEvent(const dtk::SizeHintEvent& event) + void DetailsWidget::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); - _setSizeHint(_bellows->isVisible(false) ? _bellows->getSizeHint() : dtk::Size2I()); + _setSizeHint(_bellows->isVisible(false) ? _bellows->getSizeHint() : feather_tk::Size2I()); } void DetailsWidget::_textUpdate() @@ -141,7 +141,7 @@ namespace toucan { _text.push_back(std::make_pair( "Enabled:", - dtk::Format("{0}").arg(item->enabled()))); + feather_tk::Format("{0}").arg(item->enabled()))); std::string text; if (item->source_range().has_value()) { @@ -174,14 +174,14 @@ namespace toucan for (const auto& text : _text) { auto context = getContext(); - auto label = dtk::Label::create(context, text.first, _layout); - label->setMarginRole(dtk::SizeRole::MarginSmall); + auto label = feather_tk::Label::create(context, text.first, _layout); + label->setMarginRole(feather_tk::SizeRole::MarginSmall); _layout->setGridPos(label, row, 0); - std::shared_ptr label2; + std::shared_ptr label2; if (!text.second.empty()) { - label2 = dtk::Label::create(context, text.second, _layout); - label2->setMarginRole(dtk::SizeRole::MarginSmall); + label2 = feather_tk::Label::create(context, text.second, _layout); + label2->setMarginRole(feather_tk::SizeRole::MarginSmall); _layout->setGridPos(label2, row, 1); } _labels.push_back(std::make_pair(label, label2)); @@ -198,8 +198,8 @@ namespace toucan if (!_search.empty()) { visible &= - dtk::contains(_text[i].first, _search, dtk::CaseCompare::Insensitive) || - dtk::contains(_text[i].second, _search, dtk::CaseCompare::Insensitive); + feather_tk::contains(_text[i].first, _search, feather_tk::CaseCompare::Insensitive) || + feather_tk::contains(_text[i].second, _search, feather_tk::CaseCompare::Insensitive); } _labels[i].first->setVisible(visible); if (_labels[i].second) @@ -215,41 +215,41 @@ namespace toucan } void DetailsTool::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IToolWidget::_init(context, app, "toucan::DetailsTool", "Details", parent); _app = app; - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::None); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::None); - _scrollWidget = dtk::ScrollWidget::create(context, dtk::ScrollType::Both, _layout); + _scrollWidget = feather_tk::ScrollWidget::create(context, feather_tk::ScrollType::Both, _layout); _scrollWidget->setBorder(false); - _scrollWidget->setVStretch(dtk::Stretch::Expanding); + _scrollWidget->setVStretch(feather_tk::Stretch::Expanding); - _scrollLayout = dtk::VerticalLayout::create(context); - _scrollLayout->setSpacingRole(dtk::SizeRole::None); + _scrollLayout = feather_tk::VerticalLayout::create(context); + _scrollLayout->setSpacingRole(feather_tk::SizeRole::None); _scrollWidget->setWidget(_scrollLayout); - dtk::Divider::create(context, dtk::Orientation::Vertical, _layout); + feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, _layout); - _bottomLayout = dtk::HorizontalLayout::create(context, _layout); - _bottomLayout->setMarginRole(dtk::SizeRole::MarginSmall); - _bottomLayout->setSpacingRole(dtk::SizeRole::SpacingSmall); + _bottomLayout = feather_tk::HorizontalLayout::create(context, _layout); + _bottomLayout->setMarginRole(feather_tk::SizeRole::MarginSmall); + _bottomLayout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); - _searchBox = dtk::SearchBox::create(context, _bottomLayout); - _searchBox->setHStretch(dtk::Stretch::Expanding); + _searchBox = feather_tk::SearchBox::create(context, _bottomLayout); + _searchBox->setHStretch(feather_tk::Stretch::Expanding); _searchBox->setTooltip("Search the JSON text"); - auto hLayout = dtk::HorizontalLayout::create(context, _bottomLayout); - hLayout->setSpacingRole(dtk::SizeRole::SpacingTool); - _openButton = dtk::ToolButton::create(context, hLayout); + auto hLayout = feather_tk::HorizontalLayout::create(context, _bottomLayout); + hLayout->setSpacingRole(feather_tk::SizeRole::SpacingTool); + _openButton = feather_tk::ToolButton::create(context, hLayout); _openButton->setIcon("BellowsOpen"); _openButton->setTooltip("Open all"); - _closeButton = dtk::ToolButton::create(context, hLayout); + _closeButton = feather_tk::ToolButton::create(context, hLayout); _closeButton->setIcon("BellowsClosed"); _closeButton->setTooltip("Close all"); @@ -280,13 +280,13 @@ namespace toucan } }); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { if (file) { - _selectionObserver = dtk::ListObserver::create( + _selectionObserver = feather_tk::ListObserver::create( file->getSelectionModel()->observeSelection(), [this, file](const std::vector& selection) { @@ -330,22 +330,22 @@ namespace toucan {} std::shared_ptr DetailsTool::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new DetailsTool); out->_init(context, app, parent); return out; } - void DetailsTool::setGeometry(const dtk::Box2I& value) + void DetailsTool::setGeometry(const feather_tk::Box2I& value) { IToolWidget::setGeometry(value); _layout->setGeometry(value); } - void DetailsTool::sizeHintEvent(const dtk::SizeHintEvent& event) + void DetailsTool::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IToolWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); diff --git a/lib/toucanView/DetailsTool.h b/lib/toucanView/DetailsTool.h index 8842982..ca84b68 100644 --- a/lib/toucanView/DetailsTool.h +++ b/lib/toucanView/DetailsTool.h @@ -9,16 +9,16 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -27,11 +27,11 @@ namespace toucan class File; //! Details widget. - class DetailsWidget : public dtk::IWidget + class DetailsWidget : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const SelectionItem&, @@ -42,7 +42,7 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const SelectionItem&, @@ -54,8 +54,8 @@ namespace toucan //! Set the search. void setSearch(const std::string&); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: void _textUpdate(); @@ -68,13 +68,13 @@ namespace toucan std::vector > _text; std::string _search; - std::shared_ptr _bellows; - std::shared_ptr _layout; - std::shared_ptr _startFrameButton; - std::shared_ptr _inOutButton; - std::vector, std::shared_ptr > > _labels; + std::shared_ptr _bellows; + std::shared_ptr _layout; + std::shared_ptr _startFrameButton; + std::shared_ptr _inOutButton; + std::vector, std::shared_ptr > > _labels; - std::shared_ptr > _timeUnitsObserver; + std::shared_ptr > _timeUnitsObserver; }; //! Details tool. @@ -82,7 +82,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -91,25 +91,25 @@ namespace toucan //! Create a new tool. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: - std::shared_ptr _layout; - std::shared_ptr _scrollWidget; - std::shared_ptr _scrollLayout; + std::shared_ptr _layout; + std::shared_ptr _scrollWidget; + std::shared_ptr _scrollLayout; std::vector > _widgets; - std::shared_ptr _bottomLayout; - std::shared_ptr _searchBox; - std::shared_ptr _openButton; - std::shared_ptr _closeButton; + std::shared_ptr _bottomLayout; + std::shared_ptr _searchBox; + std::shared_ptr _openButton; + std::shared_ptr _closeButton; - std::shared_ptr > > _fileObserver; - std::shared_ptr > _selectionObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > _selectionObserver; }; } diff --git a/lib/toucanView/ExportTool.cpp b/lib/toucanView/ExportTool.cpp index 00bbb1b..aa7a91c 100644 --- a/lib/toucanView/ExportTool.cpp +++ b/lib/toucanView/ExportTool.cpp @@ -9,12 +9,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include @@ -25,12 +25,13 @@ namespace toucan { void ExportWidget::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IWidget::_init(context, "toucan::ExportWidget", parent); + _settings = app->getSettings(); _host = app->getHost(); _movieCodecs = ffmpeg::getVideoCodecStrings(); @@ -42,10 +43,10 @@ namespace toucan _widgetUpdate(); - _timer = dtk::Timer::create(context); + _timer = feather_tk::Timer::create(context); _timer->setRepeating(true); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { @@ -71,40 +72,39 @@ namespace toucan json["MovieCodec"] = ffmpeg::toString( static_cast(_movieCodecComboBox->getCurrentIndex())); auto context = getContext(); - auto settings = context->getSystem(); - settings->set("ExportWidget", json); + _settings->set("/ExportWidget", json); } std::shared_ptr ExportWidget::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new ExportWidget); out->_init(context, app, parent); return out; } - void ExportWidget::setGeometry(const dtk::Box2I& value) + void ExportWidget::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void ExportWidget::sizeHintEvent(const dtk::SizeHintEvent& event) + void ExportWidget::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); } void ExportWidget::_initSettings( - const std::shared_ptr& context, + const std::shared_ptr& context, SettingsValues& settingsValues) { try { - auto settings = context->getSystem(); - const auto json = std::any_cast(settings->get("ExportWidget")); + nlohmann::json json; + _settings->get("/ExportWidget", json); auto i = json.find("Dir"); if (i != json.end() && i->is_string()) { @@ -166,45 +166,45 @@ namespace toucan } void ExportWidget::_initCommonUI( - const std::shared_ptr& context, + const std::shared_ptr& context, const SettingsValues& settingsValues) { - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::None); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::None); - auto vLayout = dtk::VerticalLayout::create(context, _layout); - vLayout->setMarginRole(dtk::SizeRole::Margin); + auto vLayout = feather_tk::VerticalLayout::create(context, _layout); + vLayout->setMarginRole(feather_tk::SizeRole::Margin); - auto gridLayout = dtk::GridLayout::create(context, vLayout); + auto gridLayout = feather_tk::GridLayout::create(context, vLayout); - auto label = dtk::Label::create(context, "Directory:", gridLayout); + auto label = feather_tk::Label::create(context, "Directory:", gridLayout); gridLayout->setGridPos(label, 0, 0); - _dirEdit = dtk::FileEdit::create(context, gridLayout); + _dirEdit = feather_tk::FileEdit::create(context, gridLayout); _dirEdit->setPath(settingsValues.dir); - _dirEdit->setHStretch(dtk::Stretch::Expanding); + _dirEdit->setHStretch(feather_tk::Stretch::Expanding); gridLayout->setGridPos(_dirEdit, 0, 1); - label = dtk::Label::create(context, "Image size:", gridLayout); + label = feather_tk::Label::create(context, "Image size:", gridLayout); gridLayout->setGridPos(label, 1, 0); - auto hLayout = dtk::HorizontalLayout::create(context, gridLayout); - hLayout->setSpacingRole(dtk::SizeRole::SpacingSmall); + auto hLayout = feather_tk::HorizontalLayout::create(context, gridLayout); + hLayout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); gridLayout->setGridPos(hLayout, 1, 1); - _sizeComboBox = dtk::ComboBox::create( + _sizeComboBox = feather_tk::ComboBox::create( context, std::vector{ "Default", "Custom" }, hLayout); _sizeComboBox->setCurrentIndex(settingsValues.sizeChoice); - _sizeComboBox->setHStretch(dtk::Stretch::Expanding); - _widthEdit = dtk::IntEdit::create(context, hLayout); - _widthEdit->setRange(dtk::RangeI(1, 15360)); + _sizeComboBox->setHStretch(feather_tk::Stretch::Expanding); + _widthEdit = feather_tk::IntEdit::create(context, hLayout); + _widthEdit->setRange(feather_tk::RangeI(1, 15360)); _widthEdit->setValue(settingsValues.customSize.w); - _heightEdit = dtk::IntEdit::create(context, hLayout); - _heightEdit->setRange(dtk::RangeI(1, 15360)); + _heightEdit = feather_tk::IntEdit::create(context, hLayout); + _heightEdit->setRange(feather_tk::RangeI(1, 15360)); _heightEdit->setValue(settingsValues.customSize.h); - dtk::Divider::create(context, dtk::Orientation::Vertical, _layout); + feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, _layout); - _tabWidget = dtk::TabWidget::create(context, _layout); + _tabWidget = feather_tk::TabWidget::create(context, _layout); _sizeComboBox->setIndexCallback( [this](int value) @@ -214,50 +214,50 @@ namespace toucan } void ExportWidget::_initImageUI( - const std::shared_ptr& context, + const std::shared_ptr& context, const SettingsValues& settingsValues) { - auto vLayout = dtk::VerticalLayout::create(context); - vLayout->setMarginRole(dtk::SizeRole::Margin); + auto vLayout = feather_tk::VerticalLayout::create(context); + vLayout->setMarginRole(feather_tk::SizeRole::Margin); _tabWidget->addTab("Images", vLayout); - auto gridLayout = dtk::GridLayout::create(context, vLayout); + auto gridLayout = feather_tk::GridLayout::create(context, vLayout); - auto label = dtk::Label::create(context, "Base name:", gridLayout); + auto label = feather_tk::Label::create(context, "Base name:", gridLayout); gridLayout->setGridPos(label, 0, 0); - _imageBaseNameEdit = dtk::LineEdit::create(context, gridLayout); + _imageBaseNameEdit = feather_tk::LineEdit::create(context, gridLayout); _imageBaseNameEdit->setText(settingsValues.imageBaseName); - _imageBaseNameEdit->setHStretch(dtk::Stretch::Expanding); + _imageBaseNameEdit->setHStretch(feather_tk::Stretch::Expanding); gridLayout->setGridPos(_imageBaseNameEdit, 0, 1); - label = dtk::Label::create(context, "Number padding:", gridLayout); + label = feather_tk::Label::create(context, "Number padding:", gridLayout); gridLayout->setGridPos(label, 1, 0); - _imagePaddingEdit = dtk::IntEdit::create(context, gridLayout); - _imagePaddingEdit->setRange(dtk::RangeI(0, 9)); + _imagePaddingEdit = feather_tk::IntEdit::create(context, gridLayout); + _imagePaddingEdit->setRange(feather_tk::RangeI(0, 9)); _imagePaddingEdit->setValue(settingsValues.imagePadding); gridLayout->setGridPos(_imagePaddingEdit, 1, 1); - label = dtk::Label::create(context, "Extension:", gridLayout); + label = feather_tk::Label::create(context, "Extension:", gridLayout); gridLayout->setGridPos(label, 2, 0); - _imageExtensionEdit = dtk::LineEdit::create(context, gridLayout); + _imageExtensionEdit = feather_tk::LineEdit::create(context, gridLayout); _imageExtensionEdit->setText(settingsValues.imageExtension); - _imageExtensionEdit->setHStretch(dtk::Stretch::Expanding); + _imageExtensionEdit->setHStretch(feather_tk::Stretch::Expanding); gridLayout->setGridPos(_imageExtensionEdit, 2, 1); - label = dtk::Label::create(context, "Filename:", gridLayout); + label = feather_tk::Label::create(context, "Filename:", gridLayout); gridLayout->setGridPos(label, 3, 0); - _imageFilenameLabel = dtk::Label::create(context, gridLayout); - _imageFilenameLabel->setHStretch(dtk::Stretch::Expanding); + _imageFilenameLabel = feather_tk::Label::create(context, gridLayout); + _imageFilenameLabel->setHStretch(feather_tk::Stretch::Expanding); gridLayout->setGridPos(_imageFilenameLabel, 3, 1); - dtk::Divider::create(context, dtk::Orientation::Vertical, vLayout); + feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, vLayout); - _exportSequenceButton = dtk::PushButton::create( + _exportSequenceButton = feather_tk::PushButton::create( context, "Export Sequence", vLayout); - _exportFrameButton = dtk::PushButton::create( + _exportFrameButton = feather_tk::PushButton::create( context, "Export Frame", vLayout); @@ -294,48 +294,48 @@ namespace toucan } void ExportWidget::_initMovieUI( - const std::shared_ptr& context, + const std::shared_ptr& context, const SettingsValues& settingsValues) { - auto vLayout = dtk::VerticalLayout::create(context); - vLayout->setMarginRole(dtk::SizeRole::Margin); + auto vLayout = feather_tk::VerticalLayout::create(context); + vLayout->setMarginRole(feather_tk::SizeRole::Margin); _tabWidget->addTab("Movie", vLayout); _tabWidget->setCurrentTab(settingsValues.currentTab); - auto gridLayout = dtk::GridLayout::create(context, vLayout); + auto gridLayout = feather_tk::GridLayout::create(context, vLayout); - auto label = dtk::Label::create(context, "Base name:", gridLayout); + auto label = feather_tk::Label::create(context, "Base name:", gridLayout); gridLayout->setGridPos(label, 0, 0); - _movieBaseNameEdit = dtk::LineEdit::create(context, gridLayout); + _movieBaseNameEdit = feather_tk::LineEdit::create(context, gridLayout); _movieBaseNameEdit->setText(settingsValues.movieBaseName); - _movieBaseNameEdit->setHStretch(dtk::Stretch::Expanding); + _movieBaseNameEdit->setHStretch(feather_tk::Stretch::Expanding); gridLayout->setGridPos(_movieBaseNameEdit, 0, 1); - label = dtk::Label::create(context, "Extension:", gridLayout); + label = feather_tk::Label::create(context, "Extension:", gridLayout); gridLayout->setGridPos(label, 1, 0); - _movieExtensionEdit = dtk::LineEdit::create(context, gridLayout); + _movieExtensionEdit = feather_tk::LineEdit::create(context, gridLayout); _movieExtensionEdit->setText(settingsValues.movieExtension); - _movieExtensionEdit->setHStretch(dtk::Stretch::Expanding); + _movieExtensionEdit->setHStretch(feather_tk::Stretch::Expanding); gridLayout->setGridPos(_movieExtensionEdit, 1, 1); - label = dtk::Label::create(context, "Filename:", gridLayout); + label = feather_tk::Label::create(context, "Filename:", gridLayout); gridLayout->setGridPos(label, 2, 0); - _movieFilenameLabel = dtk::Label::create(context, gridLayout); - _movieFilenameLabel->setHStretch(dtk::Stretch::Expanding); + _movieFilenameLabel = feather_tk::Label::create(context, gridLayout); + _movieFilenameLabel->setHStretch(feather_tk::Stretch::Expanding); gridLayout->setGridPos(_movieFilenameLabel, 2, 1); - label = dtk::Label::create(context, "Codec:", gridLayout); + label = feather_tk::Label::create(context, "Codec:", gridLayout); gridLayout->setGridPos(label, 3, 0); - _movieCodecComboBox = dtk::ComboBox::create(context, _movieCodecs, gridLayout); + _movieCodecComboBox = feather_tk::ComboBox::create(context, _movieCodecs, gridLayout); ffmpeg::VideoCodec ffmpegVideoCodec = ffmpeg::VideoCodec::First; ffmpeg::fromString(settingsValues.movieCodec, ffmpegVideoCodec); _movieCodecComboBox->setCurrentIndex(static_cast(ffmpegVideoCodec)); - _movieCodecComboBox->setHStretch(dtk::Stretch::Expanding); + _movieCodecComboBox->setHStretch(feather_tk::Stretch::Expanding); gridLayout->setGridPos(_movieCodecComboBox, 3, 1); - dtk::Divider::create(context, dtk::Orientation::Vertical, vLayout); + feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, vLayout); - _exportMovieButton = dtk::PushButton::create( + _exportMovieButton = feather_tk::PushButton::create( context, "Export Movie", vLayout); @@ -405,11 +405,11 @@ namespace toucan default: break; } - _dialog = dtk::ProgressDialog::create( + _dialog = feather_tk::ProgressDialog::create( getContext(), "Export", "Exporting:"); - _dialog->setMessage(dtk::Format("{0} / {1}").arg(0).arg(_timeRange.duration().value())); + _dialog->setMessage(feather_tk::Format("{0} / {1}").arg(0).arg(_timeRange.duration().value())); _dialog->setCloseCallback( [this] { @@ -430,7 +430,7 @@ namespace toucan } catch (const std::exception& e) { - auto dialogSystem = getContext()->getSystem(); + auto dialogSystem = getContext()->getSystem(); dialogSystem->message("ERROR", e.what(), getWindow()); } } @@ -471,7 +471,7 @@ namespace toucan { _dialog->close(); } - getContext()->getSystem()->message( + getContext()->getSystem()->message( "ERROR", e.what(), getWindow()); @@ -489,7 +489,7 @@ namespace toucan (_time - _timeRange.start_time()).value() / static_cast(duration.value()) : 0.0; _dialog->setValue(v); - _dialog->setMessage(dtk::Format("{0} / {1}"). + _dialog->setMessage(feather_tk::Format("{0} / {1}"). arg((_time - _timeRange.start_time()).value()). arg(_timeRange.duration().value())); } @@ -519,13 +519,13 @@ namespace toucan } void ExportTool::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IToolWidget::_init(context, app, "toucan::ExportTool", "Export", parent); - _scrollWidget = dtk::ScrollWidget::create(context, dtk::ScrollType::Both, shared_from_this()); + _scrollWidget = feather_tk::ScrollWidget::create(context, feather_tk::ScrollType::Both, shared_from_this()); _scrollWidget->setBorder(false); _widget = ExportWidget::create(context, app); @@ -536,22 +536,22 @@ namespace toucan {} std::shared_ptr ExportTool::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new ExportTool); out->_init(context, app, parent); return out; } - void ExportTool::setGeometry(const dtk::Box2I& value) + void ExportTool::setGeometry(const feather_tk::Box2I& value) { IToolWidget::setGeometry(value); _scrollWidget->setGeometry(value); } - void ExportTool::sizeHintEvent(const dtk::SizeHintEvent& event) + void ExportTool::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IToolWidget::sizeHintEvent(event); _setSizeHint(_scrollWidget->getSizeHint()); diff --git a/lib/toucanView/ExportTool.h b/lib/toucanView/ExportTool.h index e5d7694..0f31e54 100644 --- a/lib/toucanView/ExportTool.h +++ b/lib/toucanView/ExportTool.h @@ -8,30 +8,31 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace toucan { class File; //! Export widget. - class ExportWidget : public dtk::IWidget + class ExportWidget : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -40,19 +41,19 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: struct SettingsValues { std::string dir; int sizeChoice = 0; - dtk::Size2I customSize = dtk::Size2I(1920, 1080); + feather_tk::Size2I customSize = feather_tk::Size2I(1920, 1080); int currentTab = 0; std::string imageBaseName = "render."; int imagePadding = 0; @@ -62,10 +63,10 @@ namespace toucan std::string movieCodec = "MJPEG"; }; - void _initSettings(const std::shared_ptr&, SettingsValues&); - void _initCommonUI(const std::shared_ptr&, const SettingsValues&); - void _initImageUI(const std::shared_ptr&, const SettingsValues&); - void _initMovieUI(const std::shared_ptr&, const SettingsValues&); + void _initSettings(const std::shared_ptr&, SettingsValues&); + void _initCommonUI(const std::shared_ptr&, const SettingsValues&); + void _initImageUI(const std::shared_ptr&, const SettingsValues&); + void _initMovieUI(const std::shared_ptr&, const SettingsValues&); enum class ExportType { @@ -79,6 +80,7 @@ namespace toucan void _widgetUpdate(); + std::shared_ptr _settings; std::shared_ptr _host; std::shared_ptr _file; OTIO_NS::TimeRange _timeRange; @@ -89,28 +91,28 @@ namespace toucan std::vector _movieCodecs; std::shared_ptr _ffWrite; - std::shared_ptr _layout; - std::shared_ptr _dirEdit; - std::shared_ptr _sizeComboBox; - std::shared_ptr _widthEdit; - std::shared_ptr _heightEdit; - std::shared_ptr _tabWidget; - std::shared_ptr _imageBaseNameEdit; - std::shared_ptr _imagePaddingEdit; - std::shared_ptr _imageExtensionEdit; - std::shared_ptr _imageFilenameLabel; - std::shared_ptr _exportSequenceButton; - std::shared_ptr _exportFrameButton; - std::shared_ptr _movieBaseNameEdit; - std::shared_ptr _movieExtensionEdit; - std::shared_ptr _movieCodecComboBox; - std::shared_ptr _movieFilenameLabel; - std::shared_ptr _exportMovieButton; - std::shared_ptr _dialog; - - std::shared_ptr _timer; - - std::shared_ptr > > _fileObserver; + std::shared_ptr _layout; + std::shared_ptr _dirEdit; + std::shared_ptr _sizeComboBox; + std::shared_ptr _widthEdit; + std::shared_ptr _heightEdit; + std::shared_ptr _tabWidget; + std::shared_ptr _imageBaseNameEdit; + std::shared_ptr _imagePaddingEdit; + std::shared_ptr _imageExtensionEdit; + std::shared_ptr _imageFilenameLabel; + std::shared_ptr _exportSequenceButton; + std::shared_ptr _exportFrameButton; + std::shared_ptr _movieBaseNameEdit; + std::shared_ptr _movieExtensionEdit; + std::shared_ptr _movieCodecComboBox; + std::shared_ptr _movieFilenameLabel; + std::shared_ptr _exportMovieButton; + std::shared_ptr _dialog; + + std::shared_ptr _timer; + + std::shared_ptr > > _fileObserver; }; //! Export tool. @@ -118,7 +120,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -127,15 +129,15 @@ namespace toucan //! Create a new tool. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: - std::shared_ptr _scrollWidget; + std::shared_ptr _scrollWidget; std::shared_ptr _widget; }; } diff --git a/lib/toucanView/File.cpp b/lib/toucanView/File.cpp index e766772..52b4429 100644 --- a/lib/toucanView/File.cpp +++ b/lib/toucanView/File.cpp @@ -10,12 +10,12 @@ #include -#include +#include namespace toucan { File::File( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& host, const std::filesystem::path& path) : _host(host), @@ -38,17 +38,17 @@ namespace toucan _timelineWrapper, _host); - _currentImage = dtk::ObservableValue >::create(); + _currentImage = feather_tk::ObservableValue >::create(); - _rootNode = dtk::ObservableValue >::create(); - _currentNode = dtk::ObservableValue >::create(); + _rootNode = feather_tk::ObservableValue >::create(); + _currentNode = feather_tk::ObservableValue >::create(); _graph = std::make_shared( context, path.parent_path(), _timelineWrapper); - _currentTimeObserver = dtk::ValueObserver::create( + _currentTimeObserver = feather_tk::ValueObserver::create( _playbackModel->observeCurrentTime(), [this](const OTIO_NS::RationalTime& value) { @@ -113,17 +113,17 @@ namespace toucan return _graph->getImageDataType(); } - std::shared_ptr > > File::observeCurrentImage() const + std::shared_ptr > > File::observeCurrentImage() const { return _currentImage; } - std::shared_ptr > > File::observeRootNode() const + std::shared_ptr > > File::observeRootNode() const { return _rootNode; } - std::shared_ptr > > File::observeCurrentNode() const + std::shared_ptr > > File::observeCurrentNode() const { return _currentNode; } @@ -138,7 +138,7 @@ namespace toucan void File::_render() { - std::shared_ptr image; + std::shared_ptr image; if (_currentNode->get()) { const OTIO_NS::TimeRange& timeRange = _playbackModel->getTimeRange(); @@ -146,15 +146,15 @@ namespace toucan _imageBuf = _currentNode->get()->exec(); const auto& spec = _imageBuf.spec(); - dtk::ImageType imageType = dtk::ImageType::None; + feather_tk::ImageType imageType = feather_tk::ImageType::None; if (OIIO::TypeDesc::UINT8 == spec.format) { switch (spec.nchannels) { - case 1: imageType = dtk::ImageType::L_U8; break; - case 2: imageType = dtk::ImageType::LA_U8; break; - case 3: imageType = dtk::ImageType::RGB_U8; break; - case 4: imageType = dtk::ImageType::RGBA_U8; break; + case 1: imageType = feather_tk::ImageType::L_U8; break; + case 2: imageType = feather_tk::ImageType::LA_U8; break; + case 3: imageType = feather_tk::ImageType::RGB_U8; break; + case 4: imageType = feather_tk::ImageType::RGBA_U8; break; default: break; } } @@ -162,10 +162,10 @@ namespace toucan { switch (spec.nchannels) { - case 1: imageType = dtk::ImageType::L_U16; break; - case 2: imageType = dtk::ImageType::LA_U16; break; - case 3: imageType = dtk::ImageType::RGB_U16; break; - case 4: imageType = dtk::ImageType::RGBA_U16; break; + case 1: imageType = feather_tk::ImageType::L_U16; break; + case 2: imageType = feather_tk::ImageType::LA_U16; break; + case 3: imageType = feather_tk::ImageType::RGB_U16; break; + case 4: imageType = feather_tk::ImageType::RGBA_U16; break; default: break; } } @@ -173,10 +173,10 @@ namespace toucan { switch (spec.nchannels) { - case 1: imageType = dtk::ImageType::L_F16; break; - case 2: imageType = dtk::ImageType::LA_F16; break; - case 3: imageType = dtk::ImageType::RGB_F16; break; - case 4: imageType = dtk::ImageType::RGBA_F16; break; + case 1: imageType = feather_tk::ImageType::L_F16; break; + case 2: imageType = feather_tk::ImageType::LA_F16; break; + case 3: imageType = feather_tk::ImageType::RGB_F16; break; + case 4: imageType = feather_tk::ImageType::RGBA_F16; break; default: break; } } @@ -184,16 +184,16 @@ namespace toucan { switch (spec.nchannels) { - case 1: imageType = dtk::ImageType::L_F32; break; - case 2: imageType = dtk::ImageType::LA_F32; break; - case 3: imageType = dtk::ImageType::RGB_F32; break; - case 4: imageType = dtk::ImageType::RGBA_F32; break; + case 1: imageType = feather_tk::ImageType::L_F32; break; + case 2: imageType = feather_tk::ImageType::LA_F32; break; + case 3: imageType = feather_tk::ImageType::RGB_F32; break; + case 4: imageType = feather_tk::ImageType::RGBA_F32; break; default: break; } } - dtk::ImageInfo info(spec.width, spec.height, imageType); + feather_tk::ImageInfo info(spec.width, spec.height, imageType); info.layout.mirror.y = true; - image = dtk::Image::create(info, reinterpret_cast(_imageBuf.localpixels())); + image = feather_tk::Image::create(info, reinterpret_cast(_imageBuf.localpixels())); } _currentImage->setIfChanged(image); } diff --git a/lib/toucanView/File.h b/lib/toucanView/File.h index 8055e0a..91cf12b 100644 --- a/lib/toucanView/File.h +++ b/lib/toucanView/File.h @@ -7,9 +7,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include @@ -25,7 +25,7 @@ namespace toucan { public: File( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::filesystem::path&); @@ -62,13 +62,13 @@ namespace toucan const std::string& getImageDataType() const; //! Observe the current image. - std::shared_ptr > > observeCurrentImage() const; + std::shared_ptr > > observeCurrentImage() const; //! Observe the root node. - std::shared_ptr > > observeRootNode() const; + std::shared_ptr > > observeRootNode() const; //! Observe the current node. - std::shared_ptr > > observeCurrentNode() const; + std::shared_ptr > > observeCurrentNode() const; //! Set the current node. void setCurrentNode(const std::shared_ptr&); @@ -83,14 +83,14 @@ namespace toucan std::shared_ptr _viewModel; std::shared_ptr _selectionModel; std::shared_ptr _thumbnailGenerator; - std::shared_ptr > > _currentImage; + std::shared_ptr > > _currentImage; OTIO_NS::RationalTime _currentTime; std::shared_ptr _graph; - std::shared_ptr > > _rootNode; - std::shared_ptr > > _currentNode; + std::shared_ptr > > _rootNode; + std::shared_ptr > > _currentNode; OIIO::ImageBuf _imageBuf; - std::shared_ptr > _currentTimeObserver; + std::shared_ptr > _currentTimeObserver; }; } diff --git a/lib/toucanView/FileMenu.cpp b/lib/toucanView/FileMenu.cpp index d29a6d3..d2c1f50 100644 --- a/lib/toucanView/FileMenu.cpp +++ b/lib/toucanView/FileMenu.cpp @@ -10,83 +10,80 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include namespace toucan { void FileMenu::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& window, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::Menu::_init(context, parent); + feather_tk::Menu::_init(context, parent); _filesModel = app->getFilesModel(); auto appWeak = std::weak_ptr(app); auto windowWeak = std::weak_ptr(window); - _actions["File/Open"] = std::make_shared( + _actions["File/Open"] = feather_tk::Action::create( "Open", "FileOpen", - dtk::Key::O, - static_cast(dtk::commandKeyModifier), + feather_tk::Key::O, + static_cast(feather_tk::commandKeyModifier), [this, appWeak, windowWeak] { auto context = getContext(); - auto fileBrowserSystem = context->getSystem(); + auto fileBrowserSystem = context->getSystem(); if (_file) { fileBrowserSystem->setPath(_file->getPath().parent_path()); } - dtk::FileBrowserOptions options = fileBrowserSystem->getOptions(); - options.extensions.clear(); - options.extensions.push_back(".otio"); - options.extensions.push_back(".otiod"); - options.extensions.push_back(".otioz"); - std::set extensionsSet; - std::vector extensions = ImageReadNode::getExtensions(); - extensionsSet.insert(extensions.begin(), extensions.end()); - extensions = SequenceReadNode::getExtensions(); - extensionsSet.insert(extensions.begin(), extensions.end()); - extensions = MovieReadNode::getExtensions(); - extensionsSet.insert(extensions.begin(), extensions.end()); - options.extensions.insert( - options.extensions.end(), - extensionsSet.begin(), - extensionsSet.end()); - fileBrowserSystem->setOptions(options); + + std::vector extensions; + std::vector extensionsTmp = ImageReadNode::getExtensions(); + extensions.insert(extensions.end(), extensionsTmp.begin(), extensionsTmp.end()); + extensionsTmp = SequenceReadNode::getExtensions(); + extensions.insert(extensions.end(), extensionsTmp.begin(), extensionsTmp.end()); + extensionsTmp = MovieReadNode::getExtensions(); + extensions.insert(extensions.end(), extensionsTmp.begin(), extensionsTmp.end()); + extensions.push_back(".otio"); + extensions.push_back(".otiod"); + extensions.push_back(".otioz"); + fileBrowserSystem->setExtensions(extensions); + + fileBrowserSystem->setRecentFilesModel(_filesModel->getRecentFilesModel()); + fileBrowserSystem->open( windowWeak.lock(), [appWeak](const std::filesystem::path& path) { appWeak.lock()->open(path); - }, - _filesModel->getRecentFilesModel()); + }); }); - _actions["File/Open"]->toolTip = "Open a file"; - addItem(_actions["File/Open"]); + _actions["File/Open"]->setTooltip("Open a file"); + addAction(_actions["File/Open"]); - _actions["File/Close"] = std::make_shared( + _actions["File/Close"] = feather_tk::Action::create( "Close", "FileClose", - dtk::Key::E, - static_cast(dtk::commandKeyModifier), + feather_tk::Key::E, + static_cast(feather_tk::commandKeyModifier), [this] { _filesModel->close(); }); - _actions["File/Close"]->toolTip = "Close the current file"; - addItem(_actions["File/Close"]); + _actions["File/Close"]->setTooltip("Close the current file"); + addAction(_actions["File/Close"]); - _actions["File/CloseAll"] = std::make_shared( + _actions["File/CloseAll"] = feather_tk::Action::create( "Close All", "FileCloseAll", - dtk::Key::E, - static_cast(dtk::KeyModifier::Shift) | static_cast(dtk::commandKeyModifier), + feather_tk::Key::E, + static_cast(feather_tk::KeyModifier::Shift) | static_cast(feather_tk::commandKeyModifier), [this] { _filesModel->closeAll(); }); - _actions["File/CloseAll"]->toolTip = "Close all files"; - addItem(_actions["File/CloseAll"]); + _actions["File/CloseAll"]->setTooltip("Close all files"); + addAction(_actions["File/CloseAll"]); addDivider(); @@ -96,28 +93,28 @@ namespace toucan _menus["Files"] = addSubMenu("Files"); - _actions["File/Next"] = std::make_shared( + _actions["File/Next"] = feather_tk::Action::create( "Next", - dtk::Key::PageDown, + feather_tk::Key::PageDown, 0, [this] { _filesModel->next(); }); - _actions["File/Next"]->toolTip = "Switch to the next file"; - addItem(_actions["File/Next"]); + _actions["File/Next"]->setTooltip("Switch to the next file"); + addAction(_actions["File/Next"]); - _actions["File/Prev"] = std::make_shared( + _actions["File/Prev"] = feather_tk::Action::create( "Previous", - dtk::Key::PageUp, + feather_tk::Key::PageUp, 0, [this] { _filesModel->prev(); }); - _actions["File/Prev"]->toolTip = "Switch to the previous file"; - addItem(_actions["File/Prev"]); + _actions["File/Prev"]->setTooltip("Switch to the previous file"); + addAction(_actions["File/Prev"]); addDivider(); - _actions["File/Exit"] = std::make_shared( + _actions["File/Exit"] = feather_tk::Action::create( "Exit", - dtk::Key::Q, - static_cast(dtk::commandKeyModifier), + feather_tk::Key::Q, + static_cast(feather_tk::commandKeyModifier), [appWeak] { if (auto app = appWeak.lock()) @@ -125,9 +122,9 @@ namespace toucan app->exit(); } }); - addItem(_actions["File/Exit"]); + addAction(_actions["File/Exit"]); - _filesObserver = dtk::ListObserver >::create( + _filesObserver = feather_tk::ListObserver >::create( _filesModel->observeFiles(), [this](const std::vector >& files) { @@ -135,19 +132,19 @@ namespace toucan _filesActions.clear(); for (int i = 0; i < files.size(); ++i) { - auto item = std::make_shared( + auto action = feather_tk::Action::create( files[i]->getPath().filename().string(), [this, i] { _filesModel->setCurrentIndex(i); close(); }); - _menus["Files"]->addItem(item); - _filesActions.push_back(item); + _menus["Files"]->addAction(action); + _filesActions.push_back(action); } }); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( _filesModel->observeCurrent(), [this](const std::shared_ptr& file) { @@ -155,17 +152,17 @@ namespace toucan _menuUpdate(); }); - _fileIndexObserver = dtk::ValueObserver::create( + _fileIndexObserver = feather_tk::ValueObserver::create( _filesModel->observeCurrentIndex(), [this](int index) { for (int i = 0; i < _filesActions.size(); ++i) { - _menus["Files"]->setItemChecked(_filesActions[i], i == index); + _menus["Files"]->setChecked(_filesActions[i], i == index); } }); - _recentFilesObserver = dtk::ListObserver::create( + _recentFilesObserver = feather_tk::ListObserver::create( _filesModel->getRecentFilesModel()->observeRecent(), [this, appWeak](const std::vector& files) { @@ -174,15 +171,15 @@ namespace toucan for (auto i = files.rbegin(); i != files.rend(); ++i) { auto file = *i; - auto item = std::make_shared( + auto action = feather_tk::Action::create( file.string(), [this, appWeak, file] { appWeak.lock()->open(file); close(); }); - _menus["RecentFiles"]->addItem(item); - _recentFilesActions.push_back(item); + _menus["RecentFiles"]->addAction(action); + _recentFilesActions.push_back(action); } }); } @@ -191,17 +188,17 @@ namespace toucan {} std::shared_ptr FileMenu::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& window, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new FileMenu); out->_init(context, app, window, parent); return out; } - const std::map >& FileMenu::getActions() const + const std::map >& FileMenu::getActions() const { return _actions; } @@ -209,10 +206,10 @@ namespace toucan void FileMenu::_menuUpdate() { const bool file = _file.get(); - setItemEnabled(_actions["File/Close"], file); - setItemEnabled(_actions["File/CloseAll"], file); + setEnabled(_actions["File/Close"], file); + setEnabled(_actions["File/CloseAll"], file); setSubMenuEnabled(_menus["Files"], file); - setItemEnabled(_actions["File/Next"], _filesActions.size() > 1); - setItemEnabled(_actions["File/Prev"], _filesActions.size() > 1); + setEnabled(_actions["File/Next"], _filesActions.size() > 1); + setEnabled(_actions["File/Prev"], _filesActions.size() > 1); } } diff --git a/lib/toucanView/FileMenu.h b/lib/toucanView/FileMenu.h index 8c0dc54..f6b61d7 100644 --- a/lib/toucanView/FileMenu.h +++ b/lib/toucanView/FileMenu.h @@ -3,9 +3,9 @@ #pragma once -#include -#include -#include +#include +#include +#include #include #include @@ -18,11 +18,11 @@ namespace toucan class MainWindow; //! File bar. - class FileMenu : public dtk::Menu + class FileMenu : public feather_tk::Menu { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -32,13 +32,13 @@ namespace toucan //! Create a new menu. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Get the actions. - const std::map >& getActions() const; + const std::map >& getActions() const; private: void _menuUpdate(); @@ -46,15 +46,15 @@ namespace toucan std::shared_ptr _filesModel; std::shared_ptr _file; - std::map > _menus; - std::map > _actions; - std::vector > _filesActions; - std::vector > _recentFilesActions; + std::map > _menus; + std::map > _actions; + std::vector > _filesActions; + std::vector > _recentFilesActions; - std::shared_ptr > > _filesObserver; - std::shared_ptr > > _fileObserver; - std::shared_ptr > _fileIndexObserver; - std::shared_ptr > _recentFilesObserver; + std::shared_ptr > > _filesObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > _fileIndexObserver; + std::shared_ptr > _recentFilesObserver; }; } diff --git a/lib/toucanView/FileTab.cpp b/lib/toucanView/FileTab.cpp index 85feb10..a6b9394 100644 --- a/lib/toucanView/FileTab.cpp +++ b/lib/toucanView/FileTab.cpp @@ -11,18 +11,18 @@ namespace toucan { void FileTab::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& file, const std::shared_ptr& parent) { - dtk::IWidget::_init(context, "toucan::FileTab", parent); + feather_tk::IWidget::_init(context, "toucan::FileTab", parent); _viewport = Viewport::create(context, app, file, shared_from_this()); _hudWidget = HUDWidget::create(context, app, file, shared_from_this()); - _viewOptionsObserver = dtk::ValueObserver::create( + _viewOptionsObserver = feather_tk::ValueObserver::create( app->getGlobalViewModel()->observeOptions(), [this](const GlobalViewOptions& value) { @@ -34,7 +34,7 @@ namespace toucan {} std::shared_ptr FileTab::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& file, const std::shared_ptr& parent) @@ -44,16 +44,16 @@ namespace toucan return out; } - void FileTab::setGeometry(const dtk::Box2I& value) + void FileTab::setGeometry(const feather_tk::Box2I& value) { - dtk::IWidget::setGeometry(value); + feather_tk::IWidget::setGeometry(value); _viewport->setGeometry(value); _hudWidget->setGeometry(value); } - void FileTab::sizeHintEvent(const dtk::SizeHintEvent& event) + void FileTab::sizeHintEvent(const feather_tk::SizeHintEvent& event) { - dtk::IWidget::sizeHintEvent(event); + feather_tk::IWidget::sizeHintEvent(event); _setSizeHint(_viewport->getSizeHint()); } } diff --git a/lib/toucanView/FileTab.h b/lib/toucanView/FileTab.h index bd5c008..181441c 100644 --- a/lib/toucanView/FileTab.h +++ b/lib/toucanView/FileTab.h @@ -5,7 +5,7 @@ #include -#include +#include namespace toucan { @@ -15,11 +15,11 @@ namespace toucan class Viewport; //! Timeline file tab. - class FileTab : public dtk::IWidget + class FileTab : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -29,18 +29,18 @@ namespace toucan //! Create a new tab. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: std::shared_ptr _viewport; std::shared_ptr _hudWidget; - std::shared_ptr > _viewOptionsObserver; + std::shared_ptr > _viewOptionsObserver; }; } diff --git a/lib/toucanView/FileToolBar.cpp b/lib/toucanView/FileToolBar.cpp index f85c46f..320a94d 100644 --- a/lib/toucanView/FileToolBar.cpp +++ b/lib/toucanView/FileToolBar.cpp @@ -9,18 +9,18 @@ namespace toucan { void FileToolBar::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::map >& actions, - const std::shared_ptr& parent) + const std::map >& actions, + const std::shared_ptr& parent) { - dtk::IWidget::_init(context, "toucan::FileToolBar", parent); + feather_tk::IWidget::_init(context, "toucan::FileToolBar", parent); - _layout = dtk::HorizontalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingSmall); + _layout = feather_tk::HorizontalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); - auto hLayout = dtk::HorizontalLayout::create(context, _layout); - hLayout->setSpacingRole(dtk::SizeRole::SpacingTool); + auto hLayout = feather_tk::HorizontalLayout::create(context, _layout); + hLayout->setSpacingRole(feather_tk::SizeRole::SpacingTool); std::vector actionNames = { "File/Open", @@ -30,23 +30,13 @@ namespace toucan for (const auto& name : actionNames) { auto i = actions.find(name); - auto button = dtk::ToolButton::create(context, hLayout); - button->setIcon(i->second->icon); - button->setTooltip(i->second->toolTip); - button->setClickedCallback( - [i] - { - if (i->second->callback) - { - i->second->callback(); - } - }); + auto button = feather_tk::ToolButton::create(context, i->second, hLayout); _buttons[name] = button; } _widgetUpdate(); - _filesObserver = dtk::ListObserver >::create( + _filesObserver = feather_tk::ListObserver >::create( app->getFilesModel()->observeFiles(), [this](const std::vector >& files) { @@ -59,23 +49,23 @@ namespace toucan {} std::shared_ptr FileToolBar::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::map >& actions, - const std::shared_ptr& parent) + const std::map >& actions, + const std::shared_ptr& parent) { auto out = std::shared_ptr(new FileToolBar); out->_init(context, app, actions, parent); return out; } - void FileToolBar::setGeometry(const dtk::Box2I& value) + void FileToolBar::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void FileToolBar::sizeHintEvent(const dtk::SizeHintEvent& event) + void FileToolBar::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); diff --git a/lib/toucanView/FileToolBar.h b/lib/toucanView/FileToolBar.h index e6e952d..d014ef9 100644 --- a/lib/toucanView/FileToolBar.h +++ b/lib/toucanView/FileToolBar.h @@ -3,10 +3,10 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include namespace toucan { @@ -14,13 +14,13 @@ namespace toucan class File; //! File tool bar. - class FileToolBar : public dtk::IWidget + class FileToolBar : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, - const std::map >&, + const std::map >&, const std::shared_ptr& parent); public: @@ -28,23 +28,23 @@ namespace toucan //! Create a new tool bar. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, - const std::map >&, + const std::map >&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: void _widgetUpdate(); size_t _filesSize = 0; - std::shared_ptr _layout; - std::map > _buttons; + std::shared_ptr _layout; + std::map > _buttons; - std::shared_ptr > > _filesObserver; + std::shared_ptr > > _filesObserver; }; } diff --git a/lib/toucanView/FilesModel.cpp b/lib/toucanView/FilesModel.cpp index bb7bfb9..7d3d188 100644 --- a/lib/toucanView/FilesModel.cpp +++ b/lib/toucanView/FilesModel.cpp @@ -5,9 +5,9 @@ #include "PlaybackModel.h" -#include -#include -#include +#include +#include +#include #include @@ -15,7 +15,7 @@ namespace toucan { - DTK_ENUM_IMPL( + FEATHER_TK_ENUM_IMPL( CompareMode, "A", "B", @@ -38,58 +38,93 @@ namespace toucan } FilesModel::FilesModel( - const std::shared_ptr& context, + const std::shared_ptr& context, + const std::shared_ptr& settings, const std::shared_ptr& host) : _context(context), - _settings(context->getSystem()), + _settings(settings), _host(host) { CompareOptions compareOptions; - try + size_t recentMax = 10; + std::vector recent; + if (_settings) { - const auto json = std::any_cast(_settings->get("FilesModel")); - auto i = json.find("CompareMode"); - if (i != json.end() && i->is_string()) + try { - std::stringstream ss(i->get()); - ss >> compareOptions.mode; - } - i = json.find("StartTime"); - if (i != json.end() && i->is_boolean()) - { - compareOptions.startTime = i->get(); - } - i = json.find("Resize"); - if (i != json.end() && i->is_boolean()) - { - compareOptions.resize = i->get(); + nlohmann::json json; + _settings->get("/FilesModel", json); + auto i = json.find("CompareMode"); + if (i != json.end() && i->is_string()) + { + std::stringstream ss(i->get()); + ss >> compareOptions.mode; + } + i = json.find("StartTime"); + if (i != json.end() && i->is_boolean()) + { + compareOptions.startTime = i->get(); + } + i = json.find("Resize"); + if (i != json.end() && i->is_boolean()) + { + compareOptions.resize = i->get(); + } + i = json.find("RecentMax"); + if (i != json.end() && i->is_number_unsigned()) + { + recentMax = i->get(); + } + i = json.find("Recent"); + if (i != json.end() && i->is_array()) + { + for (auto j = i->begin(); j != i->end(); ++j) + { + if (j->is_string()) + { + recent.push_back(std::filesystem::u8path(j->get())); + } + } + } } + catch (const std::exception&) + {} } - catch (const std::exception&) - {} - - _files = dtk::ObservableList< std::shared_ptr >::create(); - _add = dtk::ObservableValue::create(-1); - _remove = dtk::ObservableValue::create(-1); - _current = dtk::ObservableValue< std::shared_ptr >::create(nullptr); - _currentIndex = dtk::ObservableValue::create(-1); - _bFile = dtk::ObservableValue >::create(); - _bIndex = dtk::ObservableValue::create(-1); - _compareOptions = dtk::ObservableValue::create(compareOptions); - _recentFilesModel = dtk::RecentFilesModel::create(context); + + _files = feather_tk::ObservableList< std::shared_ptr >::create(); + _add = feather_tk::ObservableValue::create(-1); + _remove = feather_tk::ObservableValue::create(-1); + _current = feather_tk::ObservableValue< std::shared_ptr >::create(nullptr); + _currentIndex = feather_tk::ObservableValue::create(-1); + _bFile = feather_tk::ObservableValue >::create(); + _bIndex = feather_tk::ObservableValue::create(-1); + _compareOptions = feather_tk::ObservableValue::create(compareOptions); + _recentFilesModel = feather_tk::RecentFilesModel::create(context); + _recentFilesModel->setRecentMax(recentMax); + _recentFilesModel->setRecent(recent); } FilesModel::~FilesModel() { - nlohmann::json json; + if (_settings) { - std::stringstream ss; - ss << _compareOptions->get().mode; - json["CompareMode"] = ss.str(); + nlohmann::json json; + { + std::stringstream ss; + ss << _compareOptions->get().mode; + json["CompareMode"] = ss.str(); + } + json["StartTime"] = _compareOptions->get().startTime; + json["Resize"] = _compareOptions->get().resize; + json["RecentMax"] = _recentFilesModel->getRecentMax(); + nlohmann::json json2; + for (const auto& path : _recentFilesModel->getRecent()) + { + json2.push_back(path.u8string()); + } + json["Recent"] = json2; + _settings->set("/FilesModel", json); } - json["StartTime"] = _compareOptions->get().startTime; - json["Resize"] = _compareOptions->get().resize; - _settings->set("FilesModel", json); } void FilesModel::open(const std::filesystem::path& path) @@ -163,27 +198,27 @@ namespace toucan _currentTimeObserver.reset(); } - std::shared_ptr > > FilesModel::observeFiles() const + std::shared_ptr > > FilesModel::observeFiles() const { return _files; } - std::shared_ptr > FilesModel::observeAdd() const + std::shared_ptr > FilesModel::observeAdd() const { return _add; } - std::shared_ptr > FilesModel::observeRemove() const + std::shared_ptr > FilesModel::observeRemove() const { return _remove; } - std::shared_ptr > > FilesModel::observeCurrent() const + std::shared_ptr > > FilesModel::observeCurrent() const { return _current; } - std::shared_ptr > FilesModel::observeCurrentIndex() const + std::shared_ptr > FilesModel::observeCurrentIndex() const { return _currentIndex; } @@ -191,7 +226,7 @@ namespace toucan void FilesModel::setCurrentIndex(int value) { const auto& files = _files->get(); - const int index = dtk::clamp(value, 0, static_cast(files.size()) - 1); + const int index = feather_tk::clamp(value, 0, static_cast(files.size()) - 1); _current->setIfChanged(index >= 0 ? files[index] : nullptr); _currentIndex->setIfChanged(index); _fileUpdate(); @@ -230,7 +265,7 @@ namespace toucan return _bFile->get(); } - std::shared_ptr > > FilesModel::observeBFile() const + std::shared_ptr > > FilesModel::observeBFile() const { return _bFile; } @@ -240,7 +275,7 @@ namespace toucan return _bIndex->get(); } - std::shared_ptr > FilesModel::observeBIndex() const + std::shared_ptr > FilesModel::observeBIndex() const { return _bIndex; } @@ -248,7 +283,7 @@ namespace toucan void FilesModel::setBIndex(int value) { const auto& files = _files->get(); - const int index = dtk::clamp(value, -1, static_cast(files.size()) - 1); + const int index = feather_tk::clamp(value, -1, static_cast(files.size()) - 1); if (_bIndex->setIfChanged(index)) { auto file = _current->get(); @@ -270,7 +305,7 @@ namespace toucan return _compareOptions->get(); } - std::shared_ptr > FilesModel::observeCompareOptions() const + std::shared_ptr > FilesModel::observeCompareOptions() const { return _compareOptions; } @@ -286,7 +321,7 @@ namespace toucan } } - const std::shared_ptr& FilesModel::getRecentFilesModel() const + const std::shared_ptr& FilesModel::getRecentFilesModel() const { return _recentFilesModel; } @@ -326,7 +361,7 @@ namespace toucan { if (auto file = _current->get()) { - _currentTimeObserver = dtk::ValueObserver::create( + _currentTimeObserver = feather_tk::ValueObserver::create( file->getPlaybackModel()->observeCurrentTime(), [this](const OTIO_NS::RationalTime& value) { diff --git a/lib/toucanView/FilesModel.h b/lib/toucanView/FilesModel.h index ef53d8c..c49895e 100644 --- a/lib/toucanView/FilesModel.h +++ b/lib/toucanView/FilesModel.h @@ -6,11 +6,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace toucan { @@ -30,7 +30,7 @@ namespace toucan Count, First = A }; - DTK_ENUM(CompareMode); + FEATHER_TK_ENUM(CompareMode); //! Compare options. struct CompareOptions @@ -48,7 +48,8 @@ namespace toucan { public: FilesModel( - const std::shared_ptr&, + const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&); virtual ~FilesModel(); @@ -66,19 +67,19 @@ namespace toucan void closeAll(); //! Observe the files. - std::shared_ptr > > observeFiles() const; + std::shared_ptr > > observeFiles() const; //! Observe when a file is added. - std::shared_ptr > observeAdd() const; + std::shared_ptr > observeAdd() const; //! Observe when a file is removed. - std::shared_ptr > observeRemove() const; + std::shared_ptr > observeRemove() const; //! Observe the current file. - std::shared_ptr > > observeCurrent() const; + std::shared_ptr > > observeCurrent() const; //! Observe the current file index. - std::shared_ptr > observeCurrentIndex() const; + std::shared_ptr > observeCurrentIndex() const; //! Set the current file index. void setCurrentIndex(int); @@ -93,13 +94,13 @@ namespace toucan const std::shared_ptr& getBFile() const; //! Observe the B file. - std::shared_ptr > > observeBFile() const; + std::shared_ptr > > observeBFile() const; //! Get the B file index. int getBIndex() const; //! Observe the B file index. - std::shared_ptr > observeBIndex() const; + std::shared_ptr > observeBIndex() const; //! Set the B file index. void setBIndex(int); @@ -108,13 +109,13 @@ namespace toucan const CompareOptions& getCompareOptions() const; //! Observe the compare options. - std::shared_ptr > observeCompareOptions() const; + std::shared_ptr > observeCompareOptions() const; //! Set the compare options. void setCompareOptions(const CompareOptions&); //! Get the recent files model. - const std::shared_ptr& getRecentFilesModel() const; + const std::shared_ptr& getRecentFilesModel() const; private: std::shared_ptr _getBFile() const; @@ -122,20 +123,20 @@ namespace toucan void _fileUpdate(); - std::weak_ptr _context; - std::shared_ptr _settings; + std::weak_ptr _context; + std::shared_ptr _settings; std::shared_ptr _host; - std::shared_ptr > > _files; - std::shared_ptr > _add; - std::shared_ptr > _remove; - std::shared_ptr > > _current; - std::shared_ptr > _currentIndex; - std::shared_ptr > > _bFile; - std::shared_ptr > _bIndex; - std::shared_ptr > _compareOptions; - std::shared_ptr _recentFilesModel; - - std::shared_ptr > _currentTimeObserver; + std::shared_ptr > > _files; + std::shared_ptr > _add; + std::shared_ptr > _remove; + std::shared_ptr > > _current; + std::shared_ptr > _currentIndex; + std::shared_ptr > > _bFile; + std::shared_ptr > _bIndex; + std::shared_ptr > _compareOptions; + std::shared_ptr _recentFilesModel; + + std::shared_ptr > _currentTimeObserver; }; } diff --git a/lib/toucanView/GapItem.cpp b/lib/toucanView/GapItem.cpp index 7d68e03..850b470 100644 --- a/lib/toucanView/GapItem.cpp +++ b/lib/toucanView/GapItem.cpp @@ -3,12 +3,12 @@ #include "GapItem.h" -#include +#include namespace toucan { void GapItem::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& gap, const OTIO_NS::SerializableObject::Retainer& timeline, @@ -33,12 +33,12 @@ namespace toucan _gap = gap; _text = !gap->name().empty() ? gap->name() : "Gap"; - _color = dtk::Color4F(.3F, .3F, .3F); + _color = feather_tk::Color4F(.3F, .3F, .3F); setTooltip(gap->schema_name() + ": " + _text); - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingTool); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingTool); _label = ItemLabel::create(context, _layout); _label->setName(_text); @@ -75,7 +75,7 @@ namespace toucan {} std::shared_ptr GapItem::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& gap, const OTIO_NS::SerializableObject::Retainer& timeline, @@ -95,21 +95,21 @@ namespace toucan } } - void GapItem::setGeometry(const dtk::Box2I& value) + void GapItem::setGeometry(const feather_tk::Box2I& value) { IItem::setGeometry(value); _layout->setGeometry(value); - _geom.g2 = dtk::margin(value, -_size.border, 0, -_size.border, 0); - _geom.g3 = dtk::margin(_label->getGeometry(), -_size.border, 0, -_size.border, 0); + _geom.g2 = feather_tk::margin(value, -_size.border, 0, -_size.border, 0); + _geom.g3 = feather_tk::margin(_label->getGeometry(), -_size.border, 0, -_size.border, 0); _selectionRect = _geom.g3; } - dtk::Box2I GapItem::getChildrenClipRect() const + feather_tk::Box2I GapItem::getChildrenClipRect() const { return _geom.g2; } - void GapItem::sizeHintEvent(const dtk::SizeHintEvent& event) + void GapItem::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IItem::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -117,19 +117,19 @@ namespace toucan { _size.init = false; _size.displayScale = event.displayScale; - _size.border = event.style->getSizeRole(dtk::SizeRole::Border, event.displayScale); + _size.border = event.style->getSizeRole(feather_tk::SizeRole::Border, event.displayScale); } _setSizeHint(_layout->getSizeHint()); } void GapItem::drawEvent( - const dtk::Box2I& drawRect, - const dtk::DrawEvent& event) + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent& event) { IItem::drawEvent(drawRect, event); event.render->drawRect( _geom.g3, - _selected ? event.style->getColorRole(dtk::ColorRole::Yellow) : _color); + _selected ? event.style->getColorRole(feather_tk::ColorRole::Yellow) : _color); } void GapItem::_timeUnitsUpdate() diff --git a/lib/toucanView/GapItem.h b/lib/toucanView/GapItem.h index d189804..38cb5bf 100644 --- a/lib/toucanView/GapItem.h +++ b/lib/toucanView/GapItem.h @@ -5,7 +5,7 @@ #include -#include +#include #include @@ -16,7 +16,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::SerializableObject::Retainer&, @@ -27,7 +27,7 @@ namespace toucan //! Create a new item. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::SerializableObject::Retainer&, @@ -35,10 +35,10 @@ namespace toucan void setScale(double) override; - void setGeometry(const dtk::Box2I&) override; - dtk::Box2I getChildrenClipRect() const override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + feather_tk::Box2I getChildrenClipRect() const override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; protected: void _timeUnitsUpdate() override; @@ -48,9 +48,9 @@ namespace toucan OTIO_NS::SerializableObject::Retainer _gap; std::string _text; - dtk::Color4F _color; + feather_tk::Color4F _color; - std::shared_ptr _layout; + std::shared_ptr _layout; std::shared_ptr _label; std::shared_ptr _markerLayout; std::vector > _markerItems; @@ -65,8 +65,8 @@ namespace toucan struct GeomData { - dtk::Box2I g2; - dtk::Box2I g3; + feather_tk::Box2I g2; + feather_tk::Box2I g3; }; GeomData _geom; }; diff --git a/lib/toucanView/GraphTool.cpp b/lib/toucanView/GraphTool.cpp index 54ae013..c66a3f5 100644 --- a/lib/toucanView/GraphTool.cpp +++ b/lib/toucanView/GraphTool.cpp @@ -6,22 +6,22 @@ #include "App.h" #include "FilesModel.h" -#include +#include namespace toucan { void GraphWidget::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IWidget::_init(context, "toucan::GraphWidget", parent); - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setMarginRole(dtk::SizeRole::MarginLarge); - _layout->setSpacingRole(dtk::SizeRole::SpacingLarge); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setMarginRole(feather_tk::SizeRole::MarginLarge); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingLarge); - _buttonGroup = dtk::ButtonGroup::create(context, dtk::ButtonGroupType::Radio); + _buttonGroup = feather_tk::ButtonGroup::create(context, feather_tk::ButtonGroupType::Radio); _buttonGroup->setCheckedCallback( [this](int index, bool value) @@ -36,14 +36,14 @@ namespace toucan } }); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { _file = file; if (file) { - _rootNodeObserver = dtk::ValueObserver >::create( + _rootNodeObserver = feather_tk::ValueObserver >::create( file->observeRootNode(), [this](const std::shared_ptr& node) { @@ -52,7 +52,7 @@ namespace toucan _graphUpdate(); }); - _currentNodeObserver = dtk::ValueObserver >::create( + _currentNodeObserver = feather_tk::ValueObserver >::create( file->observeCurrentNode(), [this](const std::shared_ptr& node) { @@ -80,22 +80,22 @@ namespace toucan {} std::shared_ptr GraphWidget::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new GraphWidget); out->_init(context, app, parent); return out; } - void GraphWidget::setGeometry(const dtk::Box2I& value) + void GraphWidget::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void GraphWidget::sizeHintEvent(const dtk::SizeHintEvent& event) + void GraphWidget::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -108,12 +108,12 @@ namespace toucan _setSizeHint(_layout->getSizeHint()); } - void GraphWidget::drawEvent(const dtk::Box2I& drawRect, const dtk::DrawEvent& event) + void GraphWidget::drawEvent(const feather_tk::Box2I& drawRect, const feather_tk::DrawEvent& event) { IWidget::drawEvent(drawRect, event); if (_rootNode) { - dtk::LineOptions options; + feather_tk::LineOptions options; options.width = _size.lineWidth; _drawInputs(_rootNode, drawRect, event, options); } @@ -133,13 +133,13 @@ namespace toucan } void GraphWidget::_createNodes( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& node, int depth) { if (node) { - auto button = dtk::PushButton::create(context, node->getLabel(), _layouts[_depth - 1 - depth]); + auto button = feather_tk::PushButton::create(context, node->getLabel(), _layouts[_depth - 1 - depth]); _buttonGroup->addButton(button); _buttons.push_back(button); _nodeToButton[node] = button; @@ -153,25 +153,25 @@ namespace toucan void GraphWidget::_drawInputs( const std::shared_ptr& node, - const dtk::Box2I& drawRect, - const dtk::DrawEvent& event, - const dtk::LineOptions& options) + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent& event, + const feather_tk::LineOptions& options) { auto i = _nodeToButton.find(node); if (i != _nodeToButton.end()) { - dtk::Box2I g = i->second->getGeometry(); - const dtk::V2I start = dtk::center(g); - std::vector > lines; + feather_tk::Box2I g = i->second->getGeometry(); + const feather_tk::V2I start = feather_tk::center(g); + std::vector > lines; for (const auto& input : node->getInputs()) { auto j = _nodeToButton.find(input); if (j != _nodeToButton.end()) { g = j->second->getGeometry(); - const dtk::V2I end = dtk::center(g); - const dtk::V2I v0(start.x, (start.y + end.y) / 2); - const dtk::V2I v1(end.x, (start.y + end.y) / 2); + const feather_tk::V2I end = feather_tk::center(g); + const feather_tk::V2I v0(start.x, (start.y + end.y) / 2); + const feather_tk::V2I v1(end.x, (start.y + end.y) / 2); lines.push_back(std::make_pair(start, v0)); lines.push_back(std::make_pair(v0, v1)); lines.push_back(std::make_pair(v1, end)); @@ -179,7 +179,7 @@ namespace toucan } event.render->drawLines( lines, - event.style->getColorRole(dtk::ColorRole::Checked), + event.style->getColorRole(feather_tk::ColorRole::Checked), options); for (const auto& input : node->getInputs()) { @@ -204,30 +204,30 @@ namespace toucan auto context = getContext(); for (int i = 0; i < _depth; ++i) { - auto layout = dtk::HorizontalLayout::create(context, _layout); - auto spacer = dtk::Spacer::create(context, dtk::Orientation::Horizontal, layout); - spacer->setSpacingRole(dtk::SizeRole::None); - spacer->setStretch(dtk::Stretch::Expanding); + auto layout = feather_tk::HorizontalLayout::create(context, _layout); + auto spacer = feather_tk::Spacer::create(context, feather_tk::Orientation::Horizontal, layout); + spacer->setSpacingRole(feather_tk::SizeRole::None); + spacer->setStretch(feather_tk::Stretch::Expanding); _layouts.push_back(layout); } _createNodes(context, _rootNode); for (const auto& layout : _layouts) { - auto spacer = dtk::Spacer::create(context, dtk::Orientation::Horizontal, layout); - spacer->setSpacingRole(dtk::SizeRole::None); - spacer->setStretch(dtk::Stretch::Expanding); + auto spacer = feather_tk::Spacer::create(context, feather_tk::Orientation::Horizontal, layout); + spacer->setSpacingRole(feather_tk::SizeRole::None); + spacer->setStretch(feather_tk::Stretch::Expanding); } } } void GraphTool::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IToolWidget::_init(context, app, "toucan::GraphTool", "Graph", parent); - _scrollWidget = dtk::ScrollWidget::create(context, dtk::ScrollType::Both, shared_from_this()); + _scrollWidget = feather_tk::ScrollWidget::create(context, feather_tk::ScrollType::Both, shared_from_this()); _scrollWidget->setBorder(false); _widget = GraphWidget::create(context, app); @@ -238,22 +238,22 @@ namespace toucan {} std::shared_ptr GraphTool::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new GraphTool); out->_init(context, app, parent); return out; } - void GraphTool::setGeometry(const dtk::Box2I& value) + void GraphTool::setGeometry(const feather_tk::Box2I& value) { IToolWidget::setGeometry(value); _scrollWidget->setGeometry(value); } - void GraphTool::sizeHintEvent(const dtk::SizeHintEvent& event) + void GraphTool::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IToolWidget::sizeHintEvent(event); _setSizeHint(_scrollWidget->getSizeHint()); diff --git a/lib/toucanView/GraphTool.h b/lib/toucanView/GraphTool.h index e8a11a8..384c960 100644 --- a/lib/toucanView/GraphTool.h +++ b/lib/toucanView/GraphTool.h @@ -7,21 +7,21 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include namespace toucan { class File; //! Image graph widget. - class GraphWidget : public dtk::IWidget + class GraphWidget : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -30,27 +30,27 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; private: int _getDepth(const std::shared_ptr&, int = 0) const; void _createNodes( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, int = 0); void _drawInputs( const std::shared_ptr&, - const dtk::Box2I& drawRect, - const dtk::DrawEvent&, - const dtk::LineOptions&); + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent&, + const feather_tk::LineOptions&); void _graphUpdate(); @@ -59,12 +59,12 @@ namespace toucan int _depth = 0; std::shared_ptr _currentNode; - std::shared_ptr _layout; - std::vector > _layouts; - std::shared_ptr _buttonGroup; - std::vector > _buttons; - std::map, std::shared_ptr > _nodeToButton; - std::map, std::shared_ptr > _buttonToNode; + std::shared_ptr _layout; + std::vector > _layouts; + std::shared_ptr _buttonGroup; + std::vector > _buttons; + std::map, std::shared_ptr > _nodeToButton; + std::map, std::shared_ptr > _buttonToNode; struct SizeData { @@ -74,9 +74,9 @@ namespace toucan }; SizeData _size; - std::shared_ptr > > _fileObserver; - std::shared_ptr > > _rootNodeObserver; - std::shared_ptr > > _currentNodeObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > > _rootNodeObserver; + std::shared_ptr > > _currentNodeObserver; }; //! Image graph tool. @@ -84,7 +84,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -93,15 +93,15 @@ namespace toucan //! Create a new tool. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: - std::shared_ptr _scrollWidget; + std::shared_ptr _scrollWidget; std::shared_ptr _widget; }; } diff --git a/lib/toucanView/HUDWidget.cpp b/lib/toucanView/HUDWidget.cpp index ca4e005..b918bbe 100644 --- a/lib/toucanView/HUDWidget.cpp +++ b/lib/toucanView/HUDWidget.cpp @@ -6,67 +6,67 @@ #include "App.h" #include "FilesModel.h" -#include -#include +#include +#include namespace toucan { void HUDWidget::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& file, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::IWidget::_init(context, "toucan::HUDWidget", parent); + feather_tk::IWidget::_init(context, "toucan::HUDWidget", parent); _file = file; - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setMarginRole(dtk::SizeRole::MarginSmall); - _layout->setSpacingRole(dtk::SizeRole::SpacingSmall); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setMarginRole(feather_tk::SizeRole::MarginSmall); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); - auto hLayout = dtk::HorizontalLayout::create(context, _layout); - hLayout->setSpacingRole(dtk::SizeRole::SpacingSmall); + auto hLayout = feather_tk::HorizontalLayout::create(context, _layout); + hLayout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); - _labels["Path"] = dtk::Label::create( + _labels["Path"] = feather_tk::Label::create( context, file->getPath().filename().string(), hLayout); - _labels["Path"]->setFontRole(dtk::FontRole::Mono); - _labels["Path"]->setMarginRole(dtk::SizeRole::MarginInside); - _labels["Path"]->setBackgroundRole(dtk::ColorRole::Overlay); + _labels["Path"]->setFontRole(feather_tk::FontRole::Mono); + _labels["Path"]->setMarginRole(feather_tk::SizeRole::MarginInside); + _labels["Path"]->setBackgroundRole(feather_tk::ColorRole::Overlay); - auto spacer = dtk::Spacer::create(context, dtk::Orientation::Horizontal, hLayout); - spacer->setHStretch(dtk::Stretch::Expanding); + auto spacer = feather_tk::Spacer::create(context, feather_tk::Orientation::Horizontal, hLayout); + spacer->setHStretch(feather_tk::Stretch::Expanding); const IMATH_NAMESPACE::V2i& imageSize = file->getImageSize(); - _labels["Image"] = dtk::Label::create( + _labels["Image"] = feather_tk::Label::create( context, - dtk::Format("{0}x{1}x{2} {3}"). + feather_tk::Format("{0}x{1}x{2} {3}"). arg(imageSize.x). arg(imageSize.y). arg(file->getImageChannels()). arg(file->getImageDataType()), hLayout); - _labels["Image"]->setFontRole(dtk::FontRole::Mono); - _labels["Image"]->setMarginRole(dtk::SizeRole::MarginInside); - _labels["Image"]->setBackgroundRole(dtk::ColorRole::Overlay); + _labels["Image"]->setFontRole(feather_tk::FontRole::Mono); + _labels["Image"]->setMarginRole(feather_tk::SizeRole::MarginInside); + _labels["Image"]->setBackgroundRole(feather_tk::ColorRole::Overlay); - spacer = dtk::Spacer::create(context, dtk::Orientation::Vertical, _layout); - spacer->setVStretch(dtk::Stretch::Expanding); + spacer = feather_tk::Spacer::create(context, feather_tk::Orientation::Vertical, _layout); + spacer->setVStretch(feather_tk::Stretch::Expanding); - hLayout = dtk::HorizontalLayout::create(context, _layout); - hLayout->setSpacingRole(dtk::SizeRole::SpacingSmall); + hLayout = feather_tk::HorizontalLayout::create(context, _layout); + hLayout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); - spacer = dtk::Spacer::create(context, dtk::Orientation::Horizontal, hLayout); - spacer->setHStretch(dtk::Stretch::Expanding); + spacer = feather_tk::Spacer::create(context, feather_tk::Orientation::Horizontal, hLayout); + spacer->setHStretch(feather_tk::Stretch::Expanding); - _labels["Time"] = dtk::Label::create(context, hLayout); - _labels["Time"]->setFontRole(dtk::FontRole::Mono); - _labels["Time"]->setMarginRole(dtk::SizeRole::MarginInside); - _labels["Time"]->setBackgroundRole(dtk::ColorRole::Overlay); + _labels["Time"] = feather_tk::Label::create(context, hLayout); + _labels["Time"]->setFontRole(feather_tk::FontRole::Mono); + _labels["Time"]->setMarginRole(feather_tk::SizeRole::MarginInside); + _labels["Time"]->setBackgroundRole(feather_tk::ColorRole::Overlay); - _currentTimeObserver = dtk::ValueObserver::create( + _currentTimeObserver = feather_tk::ValueObserver::create( file->getPlaybackModel()->observeCurrentTime(), [this](const OTIO_NS::RationalTime& value) { @@ -74,7 +74,7 @@ namespace toucan _widgetUpdate(); }); - _timeRangeObserver = dtk::ValueObserver::create( + _timeRangeObserver = feather_tk::ValueObserver::create( file->getPlaybackModel()->observeTimeRange(), [this](const OTIO_NS::TimeRange& value) { @@ -87,17 +87,17 @@ namespace toucan {} std::shared_ptr HUDWidget::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& file, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new HUDWidget); out->_init(context, app, file, parent); return out; } - void HUDWidget::setGeometry(const dtk::Box2I& value) + void HUDWidget::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); @@ -106,7 +106,7 @@ namespace toucan void HUDWidget::_widgetUpdate() { _labels["Time"]->setText( - dtk::Format("{0} / {1} - {2} @ {4}"). + feather_tk::Format("{0} / {1} - {2} @ {4}"). arg(_currentTime.value()). arg(_timeRange.start_time().value()). arg(_timeRange.end_time_inclusive().value()). diff --git a/lib/toucanView/HUDWidget.h b/lib/toucanView/HUDWidget.h index c6bba0b..69699b7 100644 --- a/lib/toucanView/HUDWidget.h +++ b/lib/toucanView/HUDWidget.h @@ -5,8 +5,8 @@ #include -#include -#include +#include +#include namespace toucan { @@ -14,11 +14,11 @@ namespace toucan class File; //! HUD widget. - class HUDWidget : public dtk::IWidget + class HUDWidget : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -28,12 +28,12 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; + void setGeometry(const feather_tk::Box2I&) override; private: void _widgetUpdate(); @@ -42,11 +42,11 @@ namespace toucan OTIO_NS::RationalTime _currentTime; OTIO_NS::TimeRange _timeRange; - std::shared_ptr _layout; - std::map > _labels; + std::shared_ptr _layout; + std::map > _labels; - std::shared_ptr > _currentTimeObserver; - std::shared_ptr > _timeRangeObserver; + std::shared_ptr > _currentTimeObserver; + std::shared_ptr > _timeRangeObserver; }; } diff --git a/lib/toucanView/IItem.cpp b/lib/toucanView/IItem.cpp index e33a2d1..6155c6f 100644 --- a/lib/toucanView/IItem.cpp +++ b/lib/toucanView/IItem.cpp @@ -10,7 +10,7 @@ namespace toucan { void IItem::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& object, const OTIO_NS::TimeRange& timeRange, @@ -23,7 +23,7 @@ namespace toucan _file = data.file; _object = object; - _timeUnitsObserver = dtk::ValueObserver::create( + _timeUnitsObserver = feather_tk::ValueObserver::create( data.app->getTimeUnitsModel()->observeTimeUnits(), [this](TimeUnits value) { @@ -40,7 +40,7 @@ namespace toucan return _object; } - const dtk::Box2I& IItem::getSelectionRect() const + const feather_tk::Box2I& IItem::getSelectionRect() const { return _selectionRect; } @@ -58,20 +58,20 @@ namespace toucan _setDrawUpdate(); } - void IItem::setGeometry(const dtk::Box2I& value) + void IItem::setGeometry(const feather_tk::Box2I& value) { ITimeWidget::setGeometry(value); _selectionRect = value; } - void IItem::mousePressEvent(dtk::MouseClickEvent& event) + void IItem::mousePressEvent(feather_tk::MouseClickEvent& event) { ITimeWidget::mousePressEvent(event); if ((1 == event.button && 0 == event.modifiers) || - (0 == event.button && static_cast(dtk::KeyModifier::Super) == event.modifiers)) + (0 == event.button && static_cast(feather_tk::KeyModifier::Super) == event.modifiers)) { event.accept = true; - _menu = dtk::Menu::create(getContext()); + _menu = feather_tk::Menu::create(getContext()); _buildMenu(_menu); auto weak = std::weak_ptr(std::dynamic_pointer_cast(shared_from_this())); _menu->setCloseCallback( @@ -84,11 +84,11 @@ namespace toucan }); _menu->open( getWindow(), - dtk::Box2I(event.pos.x, event.pos.y, 0, 0)); + feather_tk::Box2I(event.pos.x, event.pos.y, 0, 0)); } } - void IItem::mouseReleaseEvent(dtk::MouseClickEvent& event) + void IItem::mouseReleaseEvent(feather_tk::MouseClickEvent& event) { ITimeWidget::mouseReleaseEvent(event); } @@ -96,9 +96,9 @@ namespace toucan void IItem::_timeUnitsUpdate() {} - void IItem::_buildMenu(const std::shared_ptr& menu) + void IItem::_buildMenu(const std::shared_ptr& menu) { - auto action = std::make_shared( + auto action = feather_tk::Action::create( "Go To Start", [this] { @@ -107,13 +107,13 @@ namespace toucan file->getPlaybackModel()->setCurrentTime(_timeRange.start_time()); } }); - menu->addItem(action); + menu->addAction(action); menu->addDivider(); if (_timeRange.duration().value() > 1.0) { - action = std::make_shared( + action = feather_tk::Action::create( "Set In/Out Points", [this] { @@ -122,10 +122,10 @@ namespace toucan file->getPlaybackModel()->setInOutRange(_timeRange); } }); - menu->addItem(action); + menu->addAction(action); } - action = std::make_shared( + action = feather_tk::Action::create( "Reset In/Out Points", [this] { @@ -134,7 +134,7 @@ namespace toucan file->getPlaybackModel()->resetInOutPoints(); } }); - menu->addItem(action); + menu->addAction(action); bool enabled = true; if (auto file = _file.lock()) { @@ -142,6 +142,6 @@ namespace toucan file->getPlaybackModel()->getInOutRange() != file->getPlaybackModel()->getTimeRange(); } - menu->setItemEnabled(action, enabled); + menu->setEnabled(action, enabled); } } diff --git a/lib/toucanView/IItem.h b/lib/toucanView/IItem.h index ccc7013..7ebe028 100644 --- a/lib/toucanView/IItem.h +++ b/lib/toucanView/IItem.h @@ -7,9 +7,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include @@ -24,7 +24,7 @@ namespace toucan std::shared_ptr app; std::shared_ptr file; std::shared_ptr thumbnailGenerator; - std::shared_ptr > > thumbnailCache; + std::shared_ptr > > thumbnailCache; }; //! Base class for timeline items. @@ -32,7 +32,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::TimeRange&, @@ -46,7 +46,7 @@ namespace toucan const OTIO_NS::SerializableObject::Retainer& getObject() const; //! Get the item selection rectangle. - const dtk::Box2I& getSelectionRect() const; + const feather_tk::Box2I& getSelectionRect() const; //! Get whether the item is selected. bool isSelected() const; @@ -54,23 +54,23 @@ namespace toucan //! Set whether the item is selected. void setSelected(bool); - void setGeometry(const dtk::Box2I&) override; - void mousePressEvent(dtk::MouseClickEvent&) override; - void mouseReleaseEvent(dtk::MouseClickEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void mousePressEvent(feather_tk::MouseClickEvent&) override; + void mouseReleaseEvent(feather_tk::MouseClickEvent&) override; protected: virtual void _timeUnitsUpdate(); - virtual void _buildMenu(const std::shared_ptr&); + virtual void _buildMenu(const std::shared_ptr&); std::weak_ptr _app; std::weak_ptr _file; OTIO_NS::SerializableObject::Retainer _object; TimeUnits _timeUnits = TimeUnits::First; - dtk::Box2I _selectionRect; + feather_tk::Box2I _selectionRect; bool _selected = false; - std::shared_ptr _menu; + std::shared_ptr _menu; private: - std::shared_ptr > _timeUnitsObserver; + std::shared_ptr > _timeUnitsObserver; }; } diff --git a/lib/toucanView/IToolWidget.cpp b/lib/toucanView/IToolWidget.cpp index 0ebcab8..98f5352 100644 --- a/lib/toucanView/IToolWidget.cpp +++ b/lib/toucanView/IToolWidget.cpp @@ -6,11 +6,11 @@ namespace toucan { void IToolWidget::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::string& objectName, const std::string& text, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IWidget::_init(context, objectName, parent); _app = app; diff --git a/lib/toucanView/IToolWidget.h b/lib/toucanView/IToolWidget.h index 19e4c93..1a0aeac 100644 --- a/lib/toucanView/IToolWidget.h +++ b/lib/toucanView/IToolWidget.h @@ -3,18 +3,18 @@ #pragma once -#include +#include namespace toucan { class App; //! Base class for tools. - class IToolWidget : public dtk::IWidget + class IToolWidget : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::string& objectName, const std::string& text, diff --git a/lib/toucanView/InfoBar.cpp b/lib/toucanView/InfoBar.cpp index 3c4c0f1..b8b49a6 100644 --- a/lib/toucanView/InfoBar.cpp +++ b/lib/toucanView/InfoBar.cpp @@ -6,24 +6,24 @@ #include "App.h" #include "FilesModel.h" -#include +#include namespace toucan { void InfoBar::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::IWidget::_init(context, "toucan::InfoBar", parent); + feather_tk::IWidget::_init(context, "toucan::InfoBar", parent); - _layout = dtk::HorizontalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingTool); + _layout = feather_tk::HorizontalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingTool); - _label = dtk::Label::create(context, _layout); - _label->setMarginRole(dtk::SizeRole::MarginInside); + _label = feather_tk::Label::create(context, _layout); + _label->setMarginRole(feather_tk::SizeRole::MarginInside); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { @@ -34,14 +34,14 @@ namespace toucan const IMATH_NAMESPACE::V2i& imageSize = file->getImageSize(); const size_t trackCount = file->getTimeline()->find_children().size(); - text = dtk::Format("{0}: {1}x{2}x{3} {4}, {5} tracks"). + text = feather_tk::Format("{0}: {1}x{2}x{3} {4}, {5} tracks"). arg(file->getPath().filename().string()). arg(imageSize.x). arg(imageSize.y). arg(file->getImageChannels()). arg(file->getImageDataType()). arg(trackCount); - tooltip = dtk::Format( + tooltip = feather_tk::Format( "Path: {0}\n" "Render: {1}x{2}, {3} image channels, {4} pixel data\n" "Tracks: {5}"). @@ -61,22 +61,22 @@ namespace toucan {} std::shared_ptr InfoBar::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new InfoBar); out->_init(context, app, parent); return out; } - void InfoBar::setGeometry(const dtk::Box2I& value) + void InfoBar::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void InfoBar::sizeHintEvent(const dtk::SizeHintEvent& event) + void InfoBar::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); diff --git a/lib/toucanView/InfoBar.h b/lib/toucanView/InfoBar.h index dd14acc..0d1e37e 100644 --- a/lib/toucanView/InfoBar.h +++ b/lib/toucanView/InfoBar.h @@ -3,11 +3,11 @@ #pragma once -#include -#include -#include +#include +#include +#include -#include +#include namespace toucan { @@ -15,11 +15,11 @@ namespace toucan class File; //! Information tool bar. - class InfoBar : public dtk::IWidget + class InfoBar : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -28,18 +28,18 @@ namespace toucan //! Create a new tool bar. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: - std::shared_ptr _layout; - std::shared_ptr _label; + std::shared_ptr _layout; + std::shared_ptr _label; - std::shared_ptr > > _fileObserver; + std::shared_ptr > > _fileObserver; }; } diff --git a/lib/toucanView/ItemLabel.cpp b/lib/toucanView/ItemLabel.cpp index a2a4c53..760b8d4 100644 --- a/lib/toucanView/ItemLabel.cpp +++ b/lib/toucanView/ItemLabel.cpp @@ -6,18 +6,18 @@ namespace toucan { void ItemLabel::_init( - const std::shared_ptr& context, - const std::shared_ptr& parent) + const std::shared_ptr& context, + const std::shared_ptr& parent) { - dtk::IWidget::_init(context, "toucan::ItemLabel", parent); + feather_tk::IWidget::_init(context, "toucan::ItemLabel", parent); } ItemLabel::~ItemLabel() {} std::shared_ptr ItemLabel::create( - const std::shared_ptr& context, - const std::shared_ptr& parent) + const std::shared_ptr& context, + const std::shared_ptr& parent) { auto out = std::shared_ptr(new ItemLabel); out->_init(context, parent); @@ -42,7 +42,7 @@ namespace toucan _setDrawUpdate(); } - void ItemLabel::setMarginRole(dtk::SizeRole value) + void ItemLabel::setMarginRole(feather_tk::SizeRole value) { if (value == _marginRole) return; @@ -51,12 +51,12 @@ namespace toucan _setDrawUpdate(); } - void ItemLabel::setGeometry(const dtk::Box2I& value) + void ItemLabel::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); } - void ItemLabel::sizeHintEvent(const dtk::SizeHintEvent& event) + void ItemLabel::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -65,15 +65,15 @@ namespace toucan _size.init = false; _size.displayScale = event.displayScale; _size.margin = event.style->getSizeRole(_marginRole, event.displayScale); - _size.margin2 = event.style->getSizeRole(dtk::SizeRole::MarginInside, event.displayScale); - _size.fontInfo = event.style->getFontRole(dtk::FontRole::Label, event.displayScale); + _size.margin2 = event.style->getSizeRole(feather_tk::SizeRole::MarginInside, event.displayScale); + _size.fontInfo = event.style->getFontRole(feather_tk::FontRole::Label, event.displayScale); _size.fontMetrics = event.fontSystem->getMetrics(_size.fontInfo); _size.nameSize = event.fontSystem->getSize(_name, _size.fontInfo); _size.durationSize = event.fontSystem->getSize(_duration, _size.fontInfo); _draw.nameGlyphs.clear(); _draw.durationGlyphs.clear(); } - dtk::Size2I sizeHint; + feather_tk::Size2I sizeHint; sizeHint.w = _size.nameSize.w + _size.margin2 * 2 + _size.durationSize.w + _size.margin2 * 2 + @@ -82,7 +82,7 @@ namespace toucan _setSizeHint(sizeHint); } - void ItemLabel::clipEvent(const dtk::Box2I& clipRect, bool clipped) + void ItemLabel::clipEvent(const feather_tk::Box2I& clipRect, bool clipped) { IWidget::clipEvent(clipRect, clipped); if (clipped) @@ -92,15 +92,15 @@ namespace toucan } } - void ItemLabel::drawEvent(const dtk::Box2I& drawRect, const dtk::DrawEvent& event) + void ItemLabel::drawEvent(const feather_tk::Box2I& drawRect, const feather_tk::DrawEvent& event) { IWidget::drawEvent(drawRect, event); - const dtk::Box2I& g = getGeometry(); - const dtk::Box2I g2 = margin(g, -_size.margin); + const feather_tk::Box2I& g = getGeometry(); + const feather_tk::Box2I g2 = margin(g, -_size.margin); int w = _size.nameSize.w + _size.margin * 2; int h = _size.fontMetrics.lineHeight; - const dtk::Box2I g3( + const feather_tk::Box2I g3( g2.min.x, g2.min.y + g2.h() / 2 - h / 2, w, @@ -112,16 +112,16 @@ namespace toucan event.render->drawText( _draw.nameGlyphs, _size.fontMetrics, - dtk::V2I(g3.min.x + _size.margin2, g3.min.y), - event.style->getColorRole(dtk::ColorRole::Text)); + feather_tk::V2I(g3.min.x + _size.margin2, g3.min.y), + event.style->getColorRole(feather_tk::ColorRole::Text)); w = _size.durationSize.w + _size.margin2 * 2; - const dtk::Box2I g4( + const feather_tk::Box2I g4( g2.max.x - w, g2.min.y + g2.h() / 2 - h / 2, w, h); - if (!dtk::intersects(g4, g3)) + if (!feather_tk::intersects(g4, g3)) { if (!_duration.empty() && _draw.durationGlyphs.empty()) { @@ -130,8 +130,8 @@ namespace toucan event.render->drawText( _draw.durationGlyphs, _size.fontMetrics, - dtk::V2I(g4.min.x + _size.margin2, g4.min.y), - event.style->getColorRole(dtk::ColorRole::Text)); + feather_tk::V2I(g4.min.x + _size.margin2, g4.min.y), + event.style->getColorRole(feather_tk::ColorRole::Text)); } } } diff --git a/lib/toucanView/ItemLabel.h b/lib/toucanView/ItemLabel.h index 9284480..9375dc9 100644 --- a/lib/toucanView/ItemLabel.h +++ b/lib/toucanView/ItemLabel.h @@ -3,16 +3,16 @@ #pragma once -#include +#include namespace toucan { //! Timeline item label. - class ItemLabel : public dtk::IWidget + class ItemLabel : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr& parent); public: @@ -20,7 +20,7 @@ namespace toucan //! Create a new label. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Set the name. @@ -30,17 +30,17 @@ namespace toucan void setDuration(const std::string&); //! Set the margin size role. - void setMarginRole(dtk::SizeRole); + void setMarginRole(feather_tk::SizeRole); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void clipEvent(const dtk::Box2I&, bool) override; - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void clipEvent(const feather_tk::Box2I&, bool) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; private: std::string _name; std::string _duration; - dtk::SizeRole _marginRole = dtk::SizeRole::MarginInside; + feather_tk::SizeRole _marginRole = feather_tk::SizeRole::MarginInside; struct SizeData { @@ -48,17 +48,17 @@ namespace toucan float displayScale = 0.F; int margin = 0; int margin2 = 0; - dtk::FontInfo fontInfo; - dtk::FontMetrics fontMetrics; - dtk::Size2I nameSize; - dtk::Size2I durationSize; + feather_tk::FontInfo fontInfo; + feather_tk::FontMetrics fontMetrics; + feather_tk::Size2I nameSize; + feather_tk::Size2I durationSize; }; SizeData _size; struct DrawData { - std::vector > nameGlyphs; - std::vector > durationGlyphs; + std::vector > nameGlyphs; + std::vector > durationGlyphs; }; DrawData _draw; }; diff --git a/lib/toucanView/JSONTool.cpp b/lib/toucanView/JSONTool.cpp index 37edf0d..9da276a 100644 --- a/lib/toucanView/JSONTool.cpp +++ b/lib/toucanView/JSONTool.cpp @@ -6,45 +6,45 @@ #include "App.h" #include "FilesModel.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace toucan { void JSONWidget::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const OTIO_NS::SerializableObject::Retainer& object, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IWidget::_init(context, "toucan::JSONWidget", parent); _object = object; - _text = dtk::split(object->to_json_string(), { '\n' }); + _text = feather_tk::split(object->to_json_string(), { '\n' }); for (int i = 0; i < _text.size(); ++i) { - _lineNumbers.push_back(dtk::Format("{0}").arg(i, dtk::digits(_text.size()), '0')); + _lineNumbers.push_back(feather_tk::Format("{0}").arg(i, feather_tk::digits(_text.size()), '0')); } - _bellows = dtk::Bellows::create(context, object->name(), shared_from_this()); + _bellows = feather_tk::Bellows::create(context, object->name(), shared_from_this()); _bellows->setOpen(true); - auto hLayout = dtk::HorizontalLayout::create(context); - hLayout->setSpacingRole(dtk::SizeRole::None); + auto hLayout = feather_tk::HorizontalLayout::create(context); + hLayout->setSpacingRole(feather_tk::SizeRole::None); _bellows->setWidget(hLayout); - _lineNumbersLabel = dtk::Label::create(context, hLayout); - _lineNumbersLabel->setBackgroundRole(dtk::ColorRole::Base); - _lineNumbersLabel->setFontRole(dtk::FontRole::Mono); - _lineNumbersLabel->setMarginRole(dtk::SizeRole::MarginSmall); - _lineNumbersLabel->setHStretch(dtk::Stretch::Fixed); + _lineNumbersLabel = feather_tk::Label::create(context, hLayout); + _lineNumbersLabel->setBackgroundRole(feather_tk::ColorRole::Base); + _lineNumbersLabel->setFontRole(feather_tk::FontRole::Mono); + _lineNumbersLabel->setMarginRole(feather_tk::SizeRole::MarginSmall); + _lineNumbersLabel->setHStretch(feather_tk::Stretch::Fixed); - _textLabel = dtk::Label::create(context, hLayout); - _textLabel->setFontRole(dtk::FontRole::Mono); - _textLabel->setMarginRole(dtk::SizeRole::MarginSmall); - _textLabel->setHStretch(dtk::Stretch::Expanding); + _textLabel = feather_tk::Label::create(context, hLayout); + _textLabel->setFontRole(feather_tk::FontRole::Mono); + _textLabel->setMarginRole(feather_tk::SizeRole::MarginSmall); + _textLabel->setHStretch(feather_tk::Stretch::Expanding); _textUpdate(); } @@ -53,9 +53,9 @@ namespace toucan {} std::shared_ptr JSONWidget::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const OTIO_NS::SerializableObject::Retainer& object, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new JSONWidget); out->_init(context, object, parent); @@ -75,13 +75,13 @@ namespace toucan _textUpdate(); } - void JSONWidget::setGeometry(const dtk::Box2I& value) + void JSONWidget::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _bellows->setGeometry(value); } - void JSONWidget::sizeHintEvent(const dtk::SizeHintEvent& event) + void JSONWidget::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); _setSizeHint(_bellows->getSizeHint()); @@ -95,56 +95,56 @@ namespace toucan std::vector text; for (size_t i = 0; i < _lineNumbers.size() && i < _text.size(); ++i) { - if (dtk::contains(_text[i], _search, dtk::CaseCompare::Insensitive)) + if (feather_tk::contains(_text[i], _search, feather_tk::CaseCompare::Insensitive)) { lineNumbers.push_back(_lineNumbers[i]); text.push_back(_text[i]); } } - _lineNumbersLabel->setText(dtk::join(lineNumbers, '\n')); - _textLabel->setText(dtk::join(text, '\n')); + _lineNumbersLabel->setText(feather_tk::join(lineNumbers, '\n')); + _textLabel->setText(feather_tk::join(text, '\n')); } else { - _lineNumbersLabel->setText(dtk::join(_lineNumbers, '\n')); - _textLabel->setText(dtk::join(_text, '\n')); + _lineNumbersLabel->setText(feather_tk::join(_lineNumbers, '\n')); + _textLabel->setText(feather_tk::join(_text, '\n')); } } void JSONTool::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IToolWidget::_init(context, app, "toucan::JSONTool", "JSON", parent); - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::None); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::None); - _scrollWidget = dtk::ScrollWidget::create(context, dtk::ScrollType::Both, _layout); + _scrollWidget = feather_tk::ScrollWidget::create(context, feather_tk::ScrollType::Both, _layout); _scrollWidget->setBorder(false); - _scrollWidget->setVStretch(dtk::Stretch::Expanding); + _scrollWidget->setVStretch(feather_tk::Stretch::Expanding); - _scrollLayout = dtk::VerticalLayout::create(context); - _scrollLayout->setSpacingRole(dtk::SizeRole::None); + _scrollLayout = feather_tk::VerticalLayout::create(context); + _scrollLayout->setSpacingRole(feather_tk::SizeRole::None); _scrollWidget->setWidget(_scrollLayout); - dtk::Divider::create(context, dtk::Orientation::Vertical, _layout); + feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, _layout); - _bottomLayout = dtk::HorizontalLayout::create(context, _layout); - _bottomLayout->setMarginRole(dtk::SizeRole::MarginSmall); - _bottomLayout->setSpacingRole(dtk::SizeRole::SpacingSmall); + _bottomLayout = feather_tk::HorizontalLayout::create(context, _layout); + _bottomLayout->setMarginRole(feather_tk::SizeRole::MarginSmall); + _bottomLayout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); - _searchBox = dtk::SearchBox::create(context, _bottomLayout); - _searchBox->setHStretch(dtk::Stretch::Expanding); + _searchBox = feather_tk::SearchBox::create(context, _bottomLayout); + _searchBox->setHStretch(feather_tk::Stretch::Expanding); _searchBox->setTooltip("Search the JSON text"); - auto hLayout = dtk::HorizontalLayout::create(context, _bottomLayout); - hLayout->setSpacingRole(dtk::SizeRole::SpacingTool); - _openButton = dtk::ToolButton::create(context, hLayout); + auto hLayout = feather_tk::HorizontalLayout::create(context, _bottomLayout); + hLayout->setSpacingRole(feather_tk::SizeRole::SpacingTool); + _openButton = feather_tk::ToolButton::create(context, hLayout); _openButton->setIcon("BellowsOpen"); _openButton->setTooltip("Open all"); - _closeButton = dtk::ToolButton::create(context, hLayout); + _closeButton = feather_tk::ToolButton::create(context, hLayout); _closeButton->setIcon("BellowsClosed"); _closeButton->setTooltip("Close all"); @@ -175,13 +175,13 @@ namespace toucan } }); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { if (file) { - _selectionObserver = dtk::ListObserver::create( + _selectionObserver = feather_tk::ListObserver::create( file->getSelectionModel()->observeSelection(), [this](const std::vector& selection) { @@ -223,22 +223,22 @@ namespace toucan {} std::shared_ptr JSONTool::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new JSONTool); out->_init(context, app, parent); return out; } - void JSONTool::setGeometry(const dtk::Box2I& value) + void JSONTool::setGeometry(const feather_tk::Box2I& value) { IToolWidget::setGeometry(value); _layout->setGeometry(value); } - void JSONTool::sizeHintEvent(const dtk::SizeHintEvent& event) + void JSONTool::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IToolWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); diff --git a/lib/toucanView/JSONTool.h b/lib/toucanView/JSONTool.h index aa8a33c..18ed79a 100644 --- a/lib/toucanView/JSONTool.h +++ b/lib/toucanView/JSONTool.h @@ -6,13 +6,13 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include @@ -21,11 +21,11 @@ namespace toucan class File; //! JSON widget. - class JSONWidget : public dtk::IWidget + class JSONWidget : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const OTIO_NS::SerializableObject::Retainer&, const std::shared_ptr& parent); @@ -34,7 +34,7 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const OTIO_NS::SerializableObject::Retainer&, const std::shared_ptr& parent = nullptr); @@ -44,8 +44,8 @@ namespace toucan //! Set the search. void setSearch(const std::string&); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: void _textUpdate(); @@ -54,9 +54,9 @@ namespace toucan std::vector _lineNumbers; std::vector _text; std::string _search; - std::shared_ptr _bellows; - std::shared_ptr _lineNumbersLabel; - std::shared_ptr _textLabel; + std::shared_ptr _bellows; + std::shared_ptr _lineNumbersLabel; + std::shared_ptr _textLabel; }; //! JSON tool. @@ -64,7 +64,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -73,27 +73,27 @@ namespace toucan //! Create a new tool. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: std::shared_ptr _file; - std::shared_ptr _layout; - std::shared_ptr _scrollWidget; - std::shared_ptr _scrollLayout; + std::shared_ptr _layout; + std::shared_ptr _scrollWidget; + std::shared_ptr _scrollLayout; std::vector > _widgets; - std::shared_ptr _bottomLayout; - std::shared_ptr _searchBox; - std::shared_ptr _openButton; - std::shared_ptr _closeButton; + std::shared_ptr _bottomLayout; + std::shared_ptr _searchBox; + std::shared_ptr _openButton; + std::shared_ptr _closeButton; - std::shared_ptr > > _fileObserver; - std::shared_ptr > _selectionObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > _selectionObserver; }; } diff --git a/lib/toucanView/LogTool.cpp b/lib/toucanView/LogTool.cpp index 27e2c43..e358855 100644 --- a/lib/toucanView/LogTool.cpp +++ b/lib/toucanView/LogTool.cpp @@ -5,9 +5,9 @@ #include "App.h" -#include -#include -#include +#include +#include +#include namespace toucan { @@ -17,36 +17,36 @@ namespace toucan } void LogTool::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IToolWidget::_init(context, app, "toucan::LogTool", "Log", parent); - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::None); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::None); - _scrollWidget = dtk::ScrollWidget::create(context, dtk::ScrollType::Both, _layout); + _scrollWidget = feather_tk::ScrollWidget::create(context, feather_tk::ScrollType::Both, _layout); _scrollWidget->setBorder(false); - _scrollWidget->setVStretch(dtk::Stretch::Expanding); + _scrollWidget->setVStretch(feather_tk::Stretch::Expanding); - _label = dtk::Label::create(context); - _label->setVAlign(dtk::VAlign::Top); - _label->setFontRole(dtk::FontRole::Mono); - _label->setMarginRole(dtk::SizeRole::MarginSmall); + _label = feather_tk::Label::create(context); + _label->setVAlign(feather_tk::VAlign::Top); + _label->setFontRole(feather_tk::FontRole::Mono); + _label->setMarginRole(feather_tk::SizeRole::MarginSmall); _scrollWidget->setWidget(_label); - dtk::Divider::create(context, dtk::Orientation::Vertical, _layout); + feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, _layout); - _bottomLayout = dtk::HorizontalLayout::create(context, _layout); - _bottomLayout->setMarginRole(dtk::SizeRole::MarginSmall); - _bottomLayout->setSpacingRole(dtk::SizeRole::SpacingSmall); + _bottomLayout = feather_tk::HorizontalLayout::create(context, _layout); + _bottomLayout->setMarginRole(feather_tk::SizeRole::MarginSmall); + _bottomLayout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); - _searchBox = dtk::SearchBox::create(context, _bottomLayout); - _searchBox->setHStretch(dtk::Stretch::Expanding); + _searchBox = feather_tk::SearchBox::create(context, _bottomLayout); + _searchBox->setHStretch(feather_tk::Stretch::Expanding); _searchBox->setTooltip("Search the log"); - _clearButton = dtk::ToolButton::create(context, _bottomLayout); + _clearButton = feather_tk::ToolButton::create(context, _bottomLayout); _clearButton->setIcon("Clear"); _clearButton->setTooltip("Clear the log"); @@ -65,13 +65,13 @@ namespace toucan _textUpdate(); }); - _logObserver = dtk::ListObserver::create( - context->getSystem()->observeLogItems(), - [this](const std::vector& items) + _logObserver = feather_tk::ListObserver::create( + context->getSystem()->observeLogItems(), + [this](const std::vector& items) { for (const auto& item : items) { - for (const auto& line : dtk::split(dtk::toString(item), '\n')) + for (const auto& line : feather_tk::split(feather_tk::toString(item), '\n')) { _text.push_back(line); } @@ -84,22 +84,22 @@ namespace toucan {} std::shared_ptr LogTool::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new LogTool); out->_init(context, app, parent); return out; } - void LogTool::setGeometry(const dtk::Box2I& value) + void LogTool::setGeometry(const feather_tk::Box2I& value) { IToolWidget::setGeometry(value); _layout->setGeometry(value); } - void LogTool::sizeHintEvent(const dtk::SizeHintEvent& event) + void LogTool::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IToolWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); @@ -122,13 +122,13 @@ namespace toucan { for (const auto& line : _text) { - if (dtk::contains(line, search, dtk::CaseCompare::Insensitive)) + if (feather_tk::contains(line, search, feather_tk::CaseCompare::Insensitive)) { text.push_back(line); } } } - _label->setText(dtk::join(text, '\n')); + _label->setText(feather_tk::join(text, '\n')); _clearButton->setEnabled(!_text.empty()); } diff --git a/lib/toucanView/LogTool.h b/lib/toucanView/LogTool.h index 37d971c..64d373e 100644 --- a/lib/toucanView/LogTool.h +++ b/lib/toucanView/LogTool.h @@ -5,12 +5,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace toucan { @@ -19,7 +19,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -28,26 +28,26 @@ namespace toucan //! Create a new tool. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: void _textUpdate(); std::list _text; - std::shared_ptr _layout; - std::shared_ptr _scrollWidget; - std::shared_ptr _label; - std::shared_ptr _bottomLayout; - std::shared_ptr _searchBox; - std::shared_ptr _clearButton; + std::shared_ptr _layout; + std::shared_ptr _scrollWidget; + std::shared_ptr _label; + std::shared_ptr _bottomLayout; + std::shared_ptr _searchBox; + std::shared_ptr _clearButton; - std::shared_ptr > _logObserver; + std::shared_ptr > _logObserver; }; } diff --git a/lib/toucanView/MainWindow.cpp b/lib/toucanView/MainWindow.cpp index 459d0fa..39c56d6 100644 --- a/lib/toucanView/MainWindow.cpp +++ b/lib/toucanView/MainWindow.cpp @@ -19,30 +19,31 @@ #include "TimelineWidget.h" #include "ToolBar.h" -#include -#include -#include -#include +#include +#include +#include +#include #include namespace toucan { void MainWindow::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::string& name, - const dtk::Size2I& size) + const feather_tk::Size2I& size) { - dtk::Window::_init(context, name, size); + feather_tk::Window::_init(context, name, size); _app = app; + _settings = app->getSettings(); float displayScale = 0.F; try { - auto settings = context->getSystem(); - const auto json = std::any_cast(settings->get("MainWindow")); + nlohmann::json json; + _settings->get("/MainWindow", json); auto i = json.find("DisplayScale"); if (i != json.end() && i->is_number()) { @@ -53,15 +54,15 @@ namespace toucan {} setDisplayScale(displayScale); - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::None); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::None); _menuBar = MenuBar::create( context, app, std::dynamic_pointer_cast(shared_from_this()), _layout); - dtk::Divider::create(context, dtk::Orientation::Vertical, _layout); + feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, _layout); _toolBar = ToolBar::create( context, @@ -69,19 +70,19 @@ namespace toucan std::dynamic_pointer_cast(shared_from_this()), _menuBar->getActions(), _layout); - _toolBarDivider = dtk::Divider::create(context, dtk::Orientation::Vertical, _layout); + _toolBarDivider = feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, _layout); - _vSplitter = dtk::Splitter::create(context, dtk::Orientation::Vertical, _layout); - _vSplitter->setSplit({ .7F, .3F }); - _vSplitter->setStretch(dtk::Stretch::Expanding); - _hSplitter = dtk::Splitter::create(context, dtk::Orientation::Horizontal, _vSplitter); - _hSplitter->setSplit({ .75F, .25F }); + _vSplitter = feather_tk::Splitter::create(context, feather_tk::Orientation::Vertical, _layout); + _vSplitter->setSplit({ .7F }); + _vSplitter->setStretch(feather_tk::Stretch::Expanding); + _hSplitter = feather_tk::Splitter::create(context, feather_tk::Orientation::Horizontal, _vSplitter); + _hSplitter->setSplit({ .75F }); - _tabWidget = dtk::TabWidget::create(context, _hSplitter); + _tabWidget = feather_tk::TabWidget::create(context, _hSplitter); _tabWidget->setTabsClosable(true); - _tabWidget->setVStretch(dtk::Stretch::Expanding); + _tabWidget->setVStretch(feather_tk::Stretch::Expanding); - _toolWidget = dtk::TabWidget::create(context, _hSplitter); + _toolWidget = feather_tk::TabWidget::create(context, _hSplitter); _toolWidgets.push_back(CompareTool::create(context, app)); _toolWidgets.push_back(DetailsTool::create(context, app)); _toolWidgets.push_back(JSONTool::create(context, app)); @@ -94,22 +95,22 @@ namespace toucan _toolWidget->addTab(toolWidget->getText(), toolWidget); } - _playbackLayout = dtk::VerticalLayout::create(context, _vSplitter); - _playbackLayout->setSpacingRole(dtk::SizeRole::None); + _playbackLayout = feather_tk::VerticalLayout::create(context, _vSplitter); + _playbackLayout->setSpacingRole(feather_tk::SizeRole::None); _playbackBar = PlaybackBar::create(context, app, _playbackLayout); - auto divider = dtk::Divider::create(context, dtk::Orientation::Vertical, _playbackLayout); + auto divider = feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, _playbackLayout); _timelineWidget = TimelineWidget::create(context, app, _playbackLayout); - _timelineWidget->setVStretch(dtk::Stretch::Expanding); + _timelineWidget->setVStretch(feather_tk::Stretch::Expanding); - _infoBarDivider = dtk::Divider::create(context, dtk::Orientation::Vertical, _layout); + _infoBarDivider = feather_tk::Divider::create(context, feather_tk::Orientation::Vertical, _layout); _infoBar = InfoBar::create(context, app, _layout); std::weak_ptr appWeak(app); - _tabWidget->setCallback( + _tabWidget->setTabCallback( [appWeak](int index) { if (auto app = appWeak.lock()) @@ -126,14 +127,14 @@ namespace toucan } }); - _filesObserver = dtk::ListObserver >::create( + _filesObserver = feather_tk::ListObserver >::create( app->getFilesModel()->observeFiles(), [this](const std::vector >& files) { _files = files; }); - _addObserver = dtk::ValueObserver::create( + _addObserver = feather_tk::ValueObserver::create( app->getFilesModel()->observeAdd(), [this, appWeak](int index) { @@ -144,14 +145,14 @@ namespace toucan auto file = _files[index]; auto tab = FileTab::create(context, app, file); _tabWidget->addTab( - dtk::elide(file->getPath().filename().string()), + feather_tk::elide(file->getPath().filename().string()), tab, file->getPath().string()); _fileTabs[file] = tab; } }); - _removeObserver = dtk::ValueObserver::create( + _removeObserver = feather_tk::ValueObserver::create( app->getFilesModel()->observeRemove(), [this, appWeak](int index) { @@ -167,14 +168,14 @@ namespace toucan } }); - _fileObserver = dtk::ValueObserver::create( + _fileObserver = feather_tk::ValueObserver::create( app->getFilesModel()->observeCurrentIndex(), [this](int index) { _tabWidget->setCurrentTab(index); }); - _componentsObserver = dtk::MapObserver::create( + _componentsObserver = feather_tk::MapObserver::create( app->getWindowModel()->observeComponents(), [this](const std::map& value) { @@ -193,7 +194,7 @@ namespace toucan _infoBar->setVisible(i->second); }); - _tooltipsObserver = dtk::ValueObserver::create( + _tooltipsObserver = feather_tk::ValueObserver::create( app->getWindowModel()->observeTooltips(), [this](bool value) { @@ -205,40 +206,38 @@ namespace toucan { nlohmann::json json; json["DisplayScale"] = getDisplayScale(); - auto context = getContext(); - auto settings = context->getSystem(); - settings->set("MainWindow", json); + _settings->set("/MainWindow", json); } std::shared_ptr MainWindow::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::string& name, - const dtk::Size2I& size) + const feather_tk::Size2I& size) { auto out = std::shared_ptr(new MainWindow); out->_init(context, app, name, size); return out; } - void MainWindow::setGeometry(const dtk::Box2I& value) + void MainWindow::setGeometry(const feather_tk::Box2I& value) { - dtk::Window::setGeometry(value); + feather_tk::Window::setGeometry(value); _layout->setGeometry(value); } - void MainWindow::sizeHintEvent(const dtk::SizeHintEvent& event) + void MainWindow::sizeHintEvent(const feather_tk::SizeHintEvent& event) { - dtk::Window::sizeHintEvent(event); + feather_tk::Window::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); } - void MainWindow::keyPressEvent(dtk::KeyEvent& event) + void MainWindow::keyPressEvent(feather_tk::KeyEvent& event) { event.accept = _menuBar->shortcut(event.key, event.modifiers); } - void MainWindow::keyReleaseEvent(dtk::KeyEvent& event) + void MainWindow::keyReleaseEvent(feather_tk::KeyEvent& event) { event.accept = true; } @@ -263,9 +262,9 @@ namespace toucan } if (!errors.empty()) { - context->getSystem()->message( + context->getSystem()->message( "ERROR", - dtk::join(errors, '\n'), + feather_tk::join(errors, '\n'), getWindow()); } } diff --git a/lib/toucanView/MainWindow.h b/lib/toucanView/MainWindow.h index 1cc6482..625d7d6 100644 --- a/lib/toucanView/MainWindow.h +++ b/lib/toucanView/MainWindow.h @@ -5,12 +5,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace toucan { @@ -25,59 +25,60 @@ namespace toucan class ToolBar; //! Main window. - class MainWindow : public dtk::Window + class MainWindow : public feather_tk::Window { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::string& name, - const dtk::Size2I&); + const feather_tk::Size2I&); public: virtual ~MainWindow(); //! Create a new window. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::string& name, - const dtk::Size2I&); + const feather_tk::Size2I&); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void keyPressEvent(dtk::KeyEvent&) override; - void keyReleaseEvent(dtk::KeyEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void keyPressEvent(feather_tk::KeyEvent&) override; + void keyReleaseEvent(feather_tk::KeyEvent&) override; protected: void _drop(const std::vector&) override; private: std::weak_ptr _app; + std::shared_ptr _settings; std::vector > _files; - std::shared_ptr _layout; + std::shared_ptr _layout; std::shared_ptr _menuBar; std::shared_ptr _toolBar; - std::shared_ptr _toolBarDivider; - std::shared_ptr _vSplitter; - std::shared_ptr _hSplitter; - std::shared_ptr _tabWidget; + std::shared_ptr _toolBarDivider; + std::shared_ptr _vSplitter; + std::shared_ptr _hSplitter; + std::shared_ptr _tabWidget; std::map, std::shared_ptr > _fileTabs; - std::shared_ptr _toolWidget; + std::shared_ptr _toolWidget; std::vector > _toolWidgets; - std::shared_ptr _playbackLayout; + std::shared_ptr _playbackLayout; std::shared_ptr _playbackBar; std::shared_ptr _timelineWidget; - std::shared_ptr _infoBarDivider; + std::shared_ptr _infoBarDivider; std::shared_ptr _infoBar; - std::shared_ptr > > _filesObserver; - std::shared_ptr > _addObserver; - std::shared_ptr > _removeObserver; - std::shared_ptr > _fileObserver; - std::shared_ptr > _componentsObserver; - std::shared_ptr > _tooltipsObserver; + std::shared_ptr > > _filesObserver; + std::shared_ptr > _addObserver; + std::shared_ptr > _removeObserver; + std::shared_ptr > _fileObserver; + std::shared_ptr > _componentsObserver; + std::shared_ptr > _tooltipsObserver; }; } diff --git a/lib/toucanView/MarkerItem.cpp b/lib/toucanView/MarkerItem.cpp index 107053b..469d99f 100644 --- a/lib/toucanView/MarkerItem.cpp +++ b/lib/toucanView/MarkerItem.cpp @@ -3,62 +3,62 @@ #include "MarkerItem.h" -#include +#include namespace toucan { - dtk::Color4F getMarkerColor(const std::string& color) + feather_tk::Color4F getMarkerColor(const std::string& color) { - dtk::Color4F out(1.F, 0.F, 0.F); + feather_tk::Color4F out(1.F, 0.F, 0.F); if (color == OTIO_NS::Marker::Color::pink) { - out = dtk::Color4F(1.F, 0.F, .5F); + out = feather_tk::Color4F(1.F, 0.F, .5F); } else if (color == OTIO_NS::Marker::Color::red) { - out = dtk::Color4F(1.F, 0.F, 0.F); + out = feather_tk::Color4F(1.F, 0.F, 0.F); } else if (color == OTIO_NS::Marker::Color::orange) { - out = dtk::Color4F(1.F, .6F, 0.F); + out = feather_tk::Color4F(1.F, .6F, 0.F); } else if (color == OTIO_NS::Marker::Color::yellow) { - out = dtk::Color4F(1.F, 1.F, 0.F); + out = feather_tk::Color4F(1.F, 1.F, 0.F); } else if (color == OTIO_NS::Marker::Color::green) { - out = dtk::Color4F(0.F, 1.F, 0.F); + out = feather_tk::Color4F(0.F, 1.F, 0.F); } else if (color == OTIO_NS::Marker::Color::cyan) { - out = dtk::Color4F(0.F, 1.F, 1.F); + out = feather_tk::Color4F(0.F, 1.F, 1.F); } else if (color == OTIO_NS::Marker::Color::blue) { - out = dtk::Color4F(0.F, 0.F, 1.F); + out = feather_tk::Color4F(0.F, 0.F, 1.F); } else if (color == OTIO_NS::Marker::Color::purple) { - out = dtk::Color4F(.5F, 0.F, 1.F); + out = feather_tk::Color4F(.5F, 0.F, 1.F); } else if (color == OTIO_NS::Marker::Color::magenta) { - out = dtk::Color4F(1.F, 0.F, 1.F); + out = feather_tk::Color4F(1.F, 0.F, 1.F); } else if (color == OTIO_NS::Marker::Color::black) { - out = dtk::Color4F(0.F, 0.F, 0.F); + out = feather_tk::Color4F(0.F, 0.F, 0.F); } else if (color == OTIO_NS::Marker::Color::white) { - out = dtk::Color4F(1.F, 1.F, 1.F); + out = feather_tk::Color4F(1.F, 1.F, 1.F); } return out; } void MarkerItem::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& marker, const OTIO_NS::TimeRange& timeRange, @@ -88,7 +88,7 @@ namespace toucan {} std::shared_ptr MarkerItem::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& marker, const OTIO_NS::TimeRange& timeRange, @@ -99,10 +99,10 @@ namespace toucan return out; } - void MarkerItem::setGeometry(const dtk::Box2I& value) + void MarkerItem::setGeometry(const feather_tk::Box2I& value) { IItem::setGeometry(value); - const dtk::Box2I g( + const feather_tk::Box2I g( value.min.x + value.h(), value.min.y, value.w() - value.h(), @@ -110,7 +110,7 @@ namespace toucan _label->setGeometry(g); } - void MarkerItem::sizeHintEvent(const dtk::SizeHintEvent& event) + void MarkerItem::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IItem::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -118,28 +118,28 @@ namespace toucan { _size.init = false; _size.displayScale = event.displayScale; - _size.margin = event.style->getSizeRole(dtk::SizeRole::MarginInside, event.displayScale); - _size.border = event.style->getSizeRole(dtk::SizeRole::Border, event.displayScale); + _size.margin = event.style->getSizeRole(feather_tk::SizeRole::MarginInside, event.displayScale); + _size.border = event.style->getSizeRole(feather_tk::SizeRole::Border, event.displayScale); } - dtk::Size2I sizeHint = _label->getSizeHint(); + feather_tk::Size2I sizeHint = _label->getSizeHint(); sizeHint.h += _size.border * 2; _setSizeHint(sizeHint); _minWidth = sizeHint.h; } void MarkerItem::drawEvent( - const dtk::Box2I& drawRect, - const dtk::DrawEvent& event) + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent& event) { IItem::drawEvent(drawRect, event); - const dtk::Box2I& g = getGeometry(); - const dtk::Box2I g2 = dtk::margin(g, -_size.border, 0, -_size.border, 0); + const feather_tk::Box2I& g = getGeometry(); + const feather_tk::Box2I g2 = feather_tk::margin(g, -_size.border, 0, -_size.border, 0); event.render->drawRect( g2, - _selected ? event.style->getColorRole(dtk::ColorRole::Yellow) : dtk::Color4F(.3F, .3F, .3F)); + _selected ? event.style->getColorRole(feather_tk::ColorRole::Yellow) : feather_tk::Color4F(.3F, .3F, .3F)); - const dtk::Box2I g3(g.min.x, g.min.y, g.h(), g.h()); - event.render->drawMesh(dtk::circle(dtk::center(g3), g3.h() / 4), _color); + const feather_tk::Box2I g3(g.min.x, g.min.y, g.h(), g.h()); + event.render->drawMesh(feather_tk::circle(feather_tk::center(g3), g3.h() / 4), _color); } void MarkerItem::_timeUnitsUpdate() diff --git a/lib/toucanView/MarkerItem.h b/lib/toucanView/MarkerItem.h index 555dae7..b8ddd17 100644 --- a/lib/toucanView/MarkerItem.h +++ b/lib/toucanView/MarkerItem.h @@ -6,21 +6,21 @@ #include #include -#include +#include #include namespace toucan { //! Get a marker color. - dtk::Color4F getMarkerColor(const std::string&); + feather_tk::Color4F getMarkerColor(const std::string&); //! Timeline marker item. class MarkerItem : public IItem { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::TimeRange&, @@ -31,15 +31,15 @@ namespace toucan //! Create a new item. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::TimeRange&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; protected: void _timeUnitsUpdate() override; @@ -49,7 +49,7 @@ namespace toucan OTIO_NS::SerializableObject::Retainer _marker; std::string _text; - dtk::Color4F _color; + feather_tk::Color4F _color; std::shared_ptr _label; diff --git a/lib/toucanView/MenuBar.cpp b/lib/toucanView/MenuBar.cpp index aa5c8c7..d2ada41 100644 --- a/lib/toucanView/MenuBar.cpp +++ b/lib/toucanView/MenuBar.cpp @@ -14,12 +14,12 @@ namespace toucan { void MenuBar::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& window, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::MenuBar::_init(context, parent); + feather_tk::MenuBar::_init(context, parent); auto fileMenu = FileMenu::create(context, app, window); addMenu("File", fileMenu); @@ -61,17 +61,17 @@ namespace toucan {} std::shared_ptr MenuBar::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& window, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new MenuBar); out->_init(context, app, window, parent); return out; } - const std::map >& MenuBar::getActions() const + const std::map >& MenuBar::getActions() const { return _actions; } diff --git a/lib/toucanView/MenuBar.h b/lib/toucanView/MenuBar.h index 951eb77..3d68756 100644 --- a/lib/toucanView/MenuBar.h +++ b/lib/toucanView/MenuBar.h @@ -3,7 +3,7 @@ #pragma once -#include +#include namespace toucan { @@ -11,11 +11,11 @@ namespace toucan class MainWindow; //! Menu bar. - class MenuBar : public dtk::MenuBar + class MenuBar : public feather_tk::MenuBar { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -25,17 +25,17 @@ namespace toucan //! Create a new menu bar. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Get the actions. - const std::map >& getActions() const; + const std::map >& getActions() const; private: - std::map > _menus; - std::map > _actions; + std::map > _menus; + std::map > _actions; }; } diff --git a/lib/toucanView/PlaybackBar.cpp b/lib/toucanView/PlaybackBar.cpp index 2c70afc..3f7d983 100644 --- a/lib/toucanView/PlaybackBar.cpp +++ b/lib/toucanView/PlaybackBar.cpp @@ -9,16 +9,16 @@ namespace toucan { void PlaybackBar::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::IWidget::_init(context, "toucan::PlaybackBar", parent); + feather_tk::IWidget::_init(context, "toucan::PlaybackBar", parent); - _layout = dtk::HorizontalLayout::create(context, shared_from_this()); - _layout->setMarginRole(dtk::SizeRole::MarginInside); - _layout->setSpacingRole(dtk::SizeRole::SpacingSmall); - _layout->setVAlign(dtk::VAlign::Center); + _layout = feather_tk::HorizontalLayout::create(context, shared_from_this()); + _layout->setMarginRole(feather_tk::SizeRole::MarginInside); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); + _layout->setVAlign(feather_tk::VAlign::Center); _playbackButtons = PlaybackButtons::create(context, _layout); @@ -30,7 +30,7 @@ namespace toucan _durationLabel = TimeLabel::create(context, app->getTimeUnitsModel(), _layout); _durationLabel->setTooltip("Timeline duration"); - _timeUnitsComboBox = dtk::ComboBox::create( + _timeUnitsComboBox = feather_tk::ComboBox::create( context, { "Timecode", "Frames", "Seconds" }, _layout); @@ -75,14 +75,14 @@ namespace toucan } }); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { _file = file; if (file) { - _timeRangeObserver = dtk::ValueObserver::create( + _timeRangeObserver = feather_tk::ValueObserver::create( file->getPlaybackModel()->observeTimeRange(), [this](const OTIO_NS::TimeRange& value) { @@ -90,7 +90,7 @@ namespace toucan _timeRangeUpdate(); }); - _currentTimeObserver = dtk::ValueObserver::create( + _currentTimeObserver = feather_tk::ValueObserver::create( file->getPlaybackModel()->observeCurrentTime(), [this](const OTIO_NS::RationalTime& value) { @@ -98,7 +98,7 @@ namespace toucan _currentTimeUpdate(); }); - _playbackObserver = dtk::ValueObserver::create( + _playbackObserver = feather_tk::ValueObserver::create( file->getPlaybackModel()->observePlayback(), [this](Playback value) { @@ -127,7 +127,7 @@ namespace toucan _durationLabel->setEnabled(file.get()); }); - _timeUnitsObserver = dtk::ValueObserver::create( + _timeUnitsObserver = feather_tk::ValueObserver::create( app->getTimeUnitsModel()->observeTimeUnits(), [this](TimeUnits value) { @@ -139,22 +139,22 @@ namespace toucan {} std::shared_ptr PlaybackBar::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new PlaybackBar); out->_init(context, app, parent); return out; } - void PlaybackBar::setGeometry(const dtk::Box2I& value) + void PlaybackBar::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void PlaybackBar::sizeHintEvent(const dtk::SizeHintEvent& event) + void PlaybackBar::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); diff --git a/lib/toucanView/PlaybackBar.h b/lib/toucanView/PlaybackBar.h index e39bb96..b3f6c27 100644 --- a/lib/toucanView/PlaybackBar.h +++ b/lib/toucanView/PlaybackBar.h @@ -6,9 +6,9 @@ #include #include -#include -#include -#include +#include +#include +#include namespace toucan { @@ -16,11 +16,11 @@ namespace toucan class File; //! Playback tool bar. - class PlaybackBar : public dtk::IWidget + class PlaybackBar : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -29,12 +29,12 @@ namespace toucan //! Create a new tool bar. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: void _timelineUpdate(); @@ -47,18 +47,18 @@ namespace toucan OTIO_NS::RationalTime _currentTime; Playback _playback = Playback::Stop; - std::shared_ptr _layout; + std::shared_ptr _layout; std::shared_ptr _frameButtons; std::shared_ptr _playbackButtons; std::shared_ptr _timeEdit; std::shared_ptr _durationLabel; - std::shared_ptr _timeUnitsComboBox; + std::shared_ptr _timeUnitsComboBox; - std::shared_ptr > > _fileObserver; - std::shared_ptr > _timeRangeObserver; - std::shared_ptr > _currentTimeObserver; - std::shared_ptr > _playbackObserver; - std::shared_ptr > _timeUnitsObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > _timeRangeObserver; + std::shared_ptr > _currentTimeObserver; + std::shared_ptr > _playbackObserver; + std::shared_ptr > _timeUnitsObserver; }; } diff --git a/lib/toucanView/PlaybackMenu.cpp b/lib/toucanView/PlaybackMenu.cpp index a8909e9..9659fb0 100644 --- a/lib/toucanView/PlaybackMenu.cpp +++ b/lib/toucanView/PlaybackMenu.cpp @@ -6,21 +6,21 @@ #include "App.h" #include "FilesModel.h" -#include +#include namespace toucan { void PlaybackMenu::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::Menu::_init(context, parent); + feather_tk::Menu::_init(context, parent); - _actions["Playback/Stop"] = std::make_shared( + _actions["Playback/Stop"] = feather_tk::Action::create( "Stop", "PlaybackStop", - dtk::Key::K, + feather_tk::Key::K, 0, [this] { @@ -29,12 +29,12 @@ namespace toucan _file->getPlaybackModel()->setPlayback(Playback::Stop); } }); - addItem(_actions["Playback/Stop"]); + addAction(_actions["Playback/Stop"]); - _actions["Playback/Forward"] = std::make_shared( + _actions["Playback/Forward"] = feather_tk::Action::create( "Forward", "PlaybackForward", - dtk::Key::L, + feather_tk::Key::L, 0, [this] { @@ -43,12 +43,12 @@ namespace toucan _file->getPlaybackModel()->setPlayback(Playback::Forward); } }); - addItem(_actions["Playback/Forward"]); + addAction(_actions["Playback/Forward"]); - _actions["Playback/Reverse"] = std::make_shared( + _actions["Playback/Reverse"] = feather_tk::Action::create( "Reverse", "PlaybackReverse", - dtk::Key::J, + feather_tk::Key::J, 0, [this] { @@ -57,13 +57,13 @@ namespace toucan _file->getPlaybackModel()->setPlayback(Playback::Reverse); } }); - addItem(_actions["Playback/Reverse"]); + addAction(_actions["Playback/Reverse"]); addDivider(); - _actions["Playback/Toggle"] = std::make_shared( + _actions["Playback/Toggle"] = feather_tk::Action::create( "Toggle Playback", - dtk::Key::Space, + feather_tk::Key::Space, 0, [this] { @@ -72,9 +72,9 @@ namespace toucan _file->getPlaybackModel()->togglePlayback(); } }); - addItem(_actions["Playback/Toggle"]); + addAction(_actions["Playback/Toggle"]); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { @@ -87,16 +87,16 @@ namespace toucan {} std::shared_ptr PlaybackMenu::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new PlaybackMenu); out->_init(context, app, parent); return out; } - const std::map >& PlaybackMenu::getActions() const + const std::map >& PlaybackMenu::getActions() const { return _actions; } @@ -106,13 +106,13 @@ namespace toucan const bool file = _file.get(); if (file) { - _playbackObserver = dtk::ValueObserver::create( + _playbackObserver = feather_tk::ValueObserver::create( _file->getPlaybackModel()->observePlayback(), [this](Playback value) { - setItemChecked(_actions["Playback/Stop"], Playback::Stop == value); - setItemChecked(_actions["Playback/Forward"], Playback::Forward == value); - setItemChecked(_actions["Playback/Reverse"], Playback::Reverse == value); + setChecked(_actions["Playback/Stop"], Playback::Stop == value); + setChecked(_actions["Playback/Forward"], Playback::Forward == value); + setChecked(_actions["Playback/Reverse"], Playback::Reverse == value); }); } else @@ -120,9 +120,9 @@ namespace toucan _playbackObserver.reset(); } - setItemEnabled(_actions["Playback/Stop"], file); - setItemEnabled(_actions["Playback/Forward"], file); - setItemEnabled(_actions["Playback/Reverse"], file); - setItemEnabled(_actions["Playback/Toggle"], file); + setEnabled(_actions["Playback/Stop"], file); + setEnabled(_actions["Playback/Forward"], file); + setEnabled(_actions["Playback/Reverse"], file); + setEnabled(_actions["Playback/Toggle"], file); } } diff --git a/lib/toucanView/PlaybackMenu.h b/lib/toucanView/PlaybackMenu.h index 7ac3a30..ed590aa 100644 --- a/lib/toucanView/PlaybackMenu.h +++ b/lib/toucanView/PlaybackMenu.h @@ -5,7 +5,7 @@ #include -#include +#include #include @@ -15,11 +15,11 @@ namespace toucan class File; //! Playback menu. - class PlaybackMenu : public dtk::Menu + class PlaybackMenu : public feather_tk::Menu { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -28,22 +28,22 @@ namespace toucan //! Create a new menu. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Get the actions. - const std::map >& getActions() const; + const std::map >& getActions() const; private: void _menuUpdate(); std::shared_ptr _file; - std::map > _actions; + std::map > _actions; - std::shared_ptr > > _fileObserver; - std::shared_ptr > _playbackObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > _playbackObserver; }; } diff --git a/lib/toucanView/PlaybackModel.cpp b/lib/toucanView/PlaybackModel.cpp index 6f16a16..911064e 100644 --- a/lib/toucanView/PlaybackModel.cpp +++ b/lib/toucanView/PlaybackModel.cpp @@ -9,13 +9,13 @@ namespace toucan { - PlaybackModel::PlaybackModel(const std::shared_ptr& context) + PlaybackModel::PlaybackModel(const std::shared_ptr& context) { - _timeRange = dtk::ObservableValue::create(); - _currentTime = dtk::ObservableValue::create(OTIO_NS::RationalTime(-1.0, -1.0)); - _inOutRange = dtk::ObservableValue::create(); - _playback = dtk::ObservableValue::create(Playback::Stop); - _timer = dtk::Timer::create(context); + _timeRange = feather_tk::ObservableValue::create(); + _currentTime = feather_tk::ObservableValue::create(OTIO_NS::RationalTime(-1.0, -1.0)); + _inOutRange = feather_tk::ObservableValue::create(); + _playback = feather_tk::ObservableValue::create(Playback::Stop); + _timer = feather_tk::Timer::create(context); _timer->setRepeating(true); } @@ -27,7 +27,7 @@ namespace toucan return _timeRange->get(); } - std::shared_ptr > PlaybackModel::observeTimeRange() const + std::shared_ptr > PlaybackModel::observeTimeRange() const { return _timeRange; } @@ -46,7 +46,7 @@ namespace toucan return _currentTime->get(); } - std::shared_ptr > PlaybackModel::observeCurrentTime() const + std::shared_ptr > PlaybackModel::observeCurrentTime() const { return _currentTime; } @@ -240,7 +240,7 @@ namespace toucan return _inOutRange->get(); } - std::shared_ptr > PlaybackModel::observeInOutRange() const + std::shared_ptr > PlaybackModel::observeInOutRange() const { return _inOutRange; } @@ -305,7 +305,7 @@ namespace toucan return _playback->get(); } - std::shared_ptr > PlaybackModel::observePlayback() const + std::shared_ptr > PlaybackModel::observePlayback() const { return _playback; } diff --git a/lib/toucanView/PlaybackModel.h b/lib/toucanView/PlaybackModel.h index 155ebf0..0c1e5fa 100644 --- a/lib/toucanView/PlaybackModel.h +++ b/lib/toucanView/PlaybackModel.h @@ -5,9 +5,9 @@ #include -#include -#include -#include +#include +#include +#include #include @@ -47,7 +47,7 @@ namespace toucan //! Timeline view state. struct TimelineViewState { - dtk::V2I pos; + feather_tk::V2I pos; double scale = 1.0; bool frameView = true; }; @@ -56,7 +56,7 @@ namespace toucan class PlaybackModel : public std::enable_shared_from_this { public: - PlaybackModel(const std::shared_ptr&); + PlaybackModel(const std::shared_ptr&); virtual ~PlaybackModel(); @@ -64,7 +64,7 @@ namespace toucan const OTIO_NS::TimeRange& getTimeRange() const; //! Observe the time range. - std::shared_ptr > observeTimeRange() const; + std::shared_ptr > observeTimeRange() const; //! Set the time range. void setTimeRange(const OTIO_NS::TimeRange&); @@ -73,7 +73,7 @@ namespace toucan const OTIO_NS::RationalTime& getCurrentTime() const; //! Observe the current time. - std::shared_ptr > observeCurrentTime() const; + std::shared_ptr > observeCurrentTime() const; //! Set the current time. void setCurrentTime( @@ -89,7 +89,7 @@ namespace toucan const OTIO_NS::TimeRange& getInOutRange() const; //! Observe the in/out range. - std::shared_ptr > observeInOutRange() const; + std::shared_ptr > observeInOutRange() const; //! Set the in/out range. void setInOutRange(const OTIO_NS::TimeRange&); @@ -113,7 +113,7 @@ namespace toucan Playback getPlayback() const; //! Observe the playback. - std::shared_ptr > observePlayback() const; + std::shared_ptr > observePlayback() const; //! Set the playback. void setPlayback(Playback); @@ -130,12 +130,12 @@ namespace toucan private: void _timeUpdate(); - std::shared_ptr > _timeRange; - std::shared_ptr > _currentTime; - std::shared_ptr > _inOutRange; - std::shared_ptr > _playback; + std::shared_ptr > _timeRange; + std::shared_ptr > _currentTime; + std::shared_ptr > _inOutRange; + std::shared_ptr > _playback; Playback _playbackPrev = Playback::Forward; std::optional _viewState; - std::shared_ptr _timer; + std::shared_ptr _timer; }; } diff --git a/lib/toucanView/SelectMenu.cpp b/lib/toucanView/SelectMenu.cpp index 1e94432..b843a87 100644 --- a/lib/toucanView/SelectMenu.cpp +++ b/lib/toucanView/SelectMenu.cpp @@ -7,21 +7,21 @@ #include "FilesModel.h" #include "SelectionModel.h" -#include +#include namespace toucan { void SelectMenu::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::Menu::_init(context, parent); + feather_tk::Menu::_init(context, parent); - _actions["Select/All"] = std::make_shared( + _actions["Select/All"] = feather_tk::Action::create( "All", - dtk::Key::A, - static_cast(dtk::commandKeyModifier), + feather_tk::Key::A, + static_cast(feather_tk::commandKeyModifier), [this] { if (_file) @@ -29,9 +29,9 @@ namespace toucan _file->getSelectionModel()->selectAll(_file->getTimeline()); } }); - addItem(_actions["Select/All"]); + addAction(_actions["Select/All"]); - _actions["Select/AllTracks"] = std::make_shared( + _actions["Select/AllTracks"] = feather_tk::Action::create( "All Tracks", [this] { @@ -42,9 +42,9 @@ namespace toucan SelectionType::Tracks); } }); - addItem(_actions["Select/AllTracks"]); + addAction(_actions["Select/AllTracks"]); - _actions["Select/AllClips"] = std::make_shared( + _actions["Select/AllClips"] = feather_tk::Action::create( "All Clips", [this] { @@ -55,9 +55,9 @@ namespace toucan SelectionType::Clips); } }); - addItem(_actions["Select/AllClips"]); + addAction(_actions["Select/AllClips"]); - _actions["Select/AllMarkers"] = std::make_shared( + _actions["Select/AllMarkers"] = feather_tk::Action::create( "All Markers", [this] { @@ -68,13 +68,13 @@ namespace toucan SelectionType::Markers); } }); - addItem(_actions["Select/AllMarkers"]); + addAction(_actions["Select/AllMarkers"]); - _actions["Select/None"] = std::make_shared( + _actions["Select/None"] = feather_tk::Action::create( "None", - dtk::Key::A, - static_cast(dtk::KeyModifier::Shift) | - static_cast(dtk::commandKeyModifier), + feather_tk::Key::A, + static_cast(feather_tk::KeyModifier::Shift) | + static_cast(feather_tk::commandKeyModifier), [this] { if (_file) @@ -82,12 +82,12 @@ namespace toucan _file->getSelectionModel()->clearSelection(); } }); - addItem(_actions["Select/None"]); + addAction(_actions["Select/None"]); - _actions["Select/Invert"] = std::make_shared( + _actions["Select/Invert"] = feather_tk::Action::create( "Invert", - dtk::Key::I, - static_cast(dtk::commandKeyModifier), + feather_tk::Key::I, + static_cast(feather_tk::commandKeyModifier), [this] { if (_file) @@ -95,9 +95,9 @@ namespace toucan _file->getSelectionModel()->invertSelection(_file->getTimeline()); } }); - addItem(_actions["Select/Invert"]); + addAction(_actions["Select/Invert"]); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { @@ -110,16 +110,16 @@ namespace toucan {} std::shared_ptr SelectMenu::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new SelectMenu); out->_init(context, app, parent); return out; } - const std::map >& SelectMenu::getActions() const + const std::map >& SelectMenu::getActions() const { return _actions; } @@ -127,11 +127,11 @@ namespace toucan void SelectMenu::_menuUpdate() { const bool file = _file.get(); - setItemEnabled(_actions["Select/All"], file); - setItemEnabled(_actions["Select/AllTracks"], file); - setItemEnabled(_actions["Select/AllClips"], file); - setItemEnabled(_actions["Select/AllMarkers"], file); - setItemEnabled(_actions["Select/None"], file); - setItemEnabled(_actions["Select/Invert"], file); + setEnabled(_actions["Select/All"], file); + setEnabled(_actions["Select/AllTracks"], file); + setEnabled(_actions["Select/AllClips"], file); + setEnabled(_actions["Select/AllMarkers"], file); + setEnabled(_actions["Select/None"], file); + setEnabled(_actions["Select/Invert"], file); } } diff --git a/lib/toucanView/SelectMenu.h b/lib/toucanView/SelectMenu.h index e0a053c..e9b548d 100644 --- a/lib/toucanView/SelectMenu.h +++ b/lib/toucanView/SelectMenu.h @@ -3,7 +3,7 @@ #pragma once -#include +#include #include @@ -13,11 +13,11 @@ namespace toucan class File; //! Select menu. - class SelectMenu : public dtk::Menu + class SelectMenu : public feather_tk::Menu { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -26,21 +26,21 @@ namespace toucan //! Create a new menu. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Get the actions. - const std::map >& getActions() const; + const std::map >& getActions() const; private: void _menuUpdate(); std::shared_ptr _file; - std::map > _actions; + std::map > _actions; - std::shared_ptr > > _fileObserver; + std::shared_ptr > > _fileObserver; }; } diff --git a/lib/toucanView/SelectionModel.cpp b/lib/toucanView/SelectionModel.cpp index 0252926..9f9a9da 100644 --- a/lib/toucanView/SelectionModel.cpp +++ b/lib/toucanView/SelectionModel.cpp @@ -41,7 +41,7 @@ namespace toucan SelectionModel::SelectionModel() { - _selection = dtk::ObservableList::create(); + _selection = feather_tk::ObservableList::create(); } SelectionModel::~SelectionModel() @@ -52,7 +52,7 @@ namespace toucan return _selection->get(); } - std::shared_ptr > SelectionModel::observeSelection() const + std::shared_ptr > SelectionModel::observeSelection() const { return _selection; } diff --git a/lib/toucanView/SelectionModel.h b/lib/toucanView/SelectionModel.h index 17a2aea..0aae61b 100644 --- a/lib/toucanView/SelectionModel.h +++ b/lib/toucanView/SelectionModel.h @@ -3,7 +3,7 @@ #pragma once -#include +#include #include @@ -46,7 +46,7 @@ namespace toucan const std::vector& getSelection() const; //! Observe the selection. - std::shared_ptr > observeSelection() const; + std::shared_ptr > observeSelection() const; //! Set the seldction. void setSelection(const std::vector&); @@ -76,6 +76,6 @@ namespace toucan const OTIO_NS::SerializableObject::Retainer&, std::vector&); - std::shared_ptr > _selection; + std::shared_ptr > _selection; }; } diff --git a/lib/toucanView/StackItem.cpp b/lib/toucanView/StackItem.cpp index f04060e..4ba4c46 100644 --- a/lib/toucanView/StackItem.cpp +++ b/lib/toucanView/StackItem.cpp @@ -5,13 +5,13 @@ #include "TrackItem.h" -#include -#include +#include +#include namespace toucan { void StackItem::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& stack, const OTIO_NS::SerializableObject::Retainer& timeline , @@ -37,12 +37,12 @@ namespace toucan _stack = stack; _text = !stack->name().empty() ? stack->name() : "Stack"; - _color = dtk::Color4F(.2F, .2F, .2F); + _color = feather_tk::Color4F(.2F, .2F, .2F); setTooltip(stack->schema_name() + ": " + _text); - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingTool); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingTool); _label = ItemLabel::create(context, _layout); _label->setName(_text); @@ -91,7 +91,7 @@ namespace toucan {} std::shared_ptr StackItem::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& stack, const OTIO_NS::SerializableObject::Retainer& timeline, @@ -112,21 +112,21 @@ namespace toucan _timeLayout->setScale(value); } - void StackItem::setGeometry(const dtk::Box2I& value) + void StackItem::setGeometry(const feather_tk::Box2I& value) { IItem::setGeometry(value); _layout->setGeometry(value); - _geom.g2 = dtk::margin(value, -_size.border, 0, -_size.border, 0); - _geom.g3 = dtk::margin(_label->getGeometry(), -_size.border, 0, -_size.border, 0); + _geom.g2 = feather_tk::margin(value, -_size.border, 0, -_size.border, 0); + _geom.g3 = feather_tk::margin(_label->getGeometry(), -_size.border, 0, -_size.border, 0); _selectionRect = _geom.g3; } - dtk::Box2I StackItem::getChildrenClipRect() const + feather_tk::Box2I StackItem::getChildrenClipRect() const { return _geom.g2; } - void StackItem::sizeHintEvent(const dtk::SizeHintEvent& event) + void StackItem::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IItem::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -134,19 +134,19 @@ namespace toucan { _size.init = false; _size.displayScale = event.displayScale; - _size.border = event.style->getSizeRole(dtk::SizeRole::Border, event.displayScale); + _size.border = event.style->getSizeRole(feather_tk::SizeRole::Border, event.displayScale); } _setSizeHint(_layout->getSizeHint()); } void StackItem::drawEvent( - const dtk::Box2I& drawRect, - const dtk::DrawEvent& event) + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent& event) { IItem::drawEvent(drawRect, event); event.render->drawRect( _geom.g3, - _selected ? event.style->getColorRole(dtk::ColorRole::Yellow) : _color); + _selected ? event.style->getColorRole(feather_tk::ColorRole::Yellow) : _color); } void StackItem::_timeUnitsUpdate() diff --git a/lib/toucanView/StackItem.h b/lib/toucanView/StackItem.h index ce65b79..d61bb5e 100644 --- a/lib/toucanView/StackItem.h +++ b/lib/toucanView/StackItem.h @@ -5,7 +5,7 @@ #include -#include +#include #include @@ -16,7 +16,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::SerializableObject::Retainer&, @@ -27,7 +27,7 @@ namespace toucan //! Create a new item. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::SerializableObject::Retainer&, @@ -35,10 +35,10 @@ namespace toucan void setScale(double) override; - void setGeometry(const dtk::Box2I&) override; - dtk::Box2I getChildrenClipRect() const override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + feather_tk::Box2I getChildrenClipRect() const override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; protected: void _timeUnitsUpdate() override; @@ -48,9 +48,9 @@ namespace toucan OTIO_NS::SerializableObject::Retainer _stack; std::string _text; - dtk::Color4F _color; + feather_tk::Color4F _color; - std::shared_ptr _layout; + std::shared_ptr _layout; std::shared_ptr _label; std::shared_ptr _markerLayout; std::vector > _markerItems; @@ -66,8 +66,8 @@ namespace toucan struct GeomData { - dtk::Box2I g2; - dtk::Box2I g3; + feather_tk::Box2I g2; + feather_tk::Box2I g3; }; GeomData _geom; }; diff --git a/lib/toucanView/ThumbnailGenerator.cpp b/lib/toucanView/ThumbnailGenerator.cpp index d4ab46b..73753b9 100644 --- a/lib/toucanView/ThumbnailGenerator.cpp +++ b/lib/toucanView/ThumbnailGenerator.cpp @@ -7,8 +7,8 @@ #include -#include -#include +#include +#include #include @@ -23,13 +23,13 @@ namespace toucan std::stringstream ss; ss << ref; s.push_back(ss.str()); - s.push_back(dtk::Format("{0}@{1}").arg(time.value()).arg(time.rate())); - s.push_back(dtk::Format("{0}").arg(height)); - return dtk::join(s, '_'); + s.push_back(feather_tk::Format("{0}@{1}").arg(time.value()).arg(time.rate())); + s.push_back(feather_tk::Format("{0}").arg(height)); + return feather_tk::join(s, '_'); } ThumbnailGenerator::ThumbnailGenerator( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::filesystem::path& path, const std::shared_ptr& timelineWrapper, const std::shared_ptr& host) : @@ -37,7 +37,7 @@ namespace toucan _timelineWrapper(timelineWrapper), _host(host) { - _logSystem = context->getSystem(); + _logSystem = context->getSystem(); _graph = std::make_shared(context, _path, _timelineWrapper); @@ -57,7 +57,7 @@ namespace toucan _logSystem->print( "toucan::ThumbnailGenerator", e.what(), - dtk::LogType::Error); + feather_tk::LogType::Error); } while (_thread.running) @@ -227,7 +227,7 @@ namespace toucan _logSystem->print( "toucan::ThumbnailGenerator", e.what(), - dtk::LogType::Error); + feather_tk::LogType::Error); } } aspectRequest->promise.set_value(aspect); @@ -256,53 +256,53 @@ namespace toucan _logSystem->print( "toucan::ThumbnailGenerator", e.what(), - dtk::LogType::Error); + feather_tk::LogType::Error); } - std::shared_ptr thumbnail; + std::shared_ptr thumbnail; const auto& spec = buf.spec(); if (spec.width > 0 && spec.height > 0) { const float aspect = spec.width / static_cast(spec.height); - const dtk::Size2I thumbnailSize(request->height * aspect, request->height); - dtk::ImageInfo info; + const feather_tk::Size2I thumbnailSize(request->height * aspect, request->height); + feather_tk::ImageInfo info; info.size = thumbnailSize; switch (spec.nchannels) { case 1: switch (spec.format.basetype) { - case OIIO::TypeDesc::UINT8: info.type = dtk::ImageType::L_U8; break; - case OIIO::TypeDesc::UINT16: info.type = dtk::ImageType::L_U16; break; - case OIIO::TypeDesc::HALF: info.type = dtk::ImageType::L_F16; break; - case OIIO::TypeDesc::FLOAT: info.type = dtk::ImageType::L_F32; break; + case OIIO::TypeDesc::UINT8: info.type = feather_tk::ImageType::L_U8; break; + case OIIO::TypeDesc::UINT16: info.type = feather_tk::ImageType::L_U16; break; + case OIIO::TypeDesc::HALF: info.type = feather_tk::ImageType::L_F16; break; + case OIIO::TypeDesc::FLOAT: info.type = feather_tk::ImageType::L_F32; break; } break; case 2: switch (spec.format.basetype) { - case OIIO::TypeDesc::UINT8: info.type = dtk::ImageType::LA_U8; break; - case OIIO::TypeDesc::UINT16: info.type = dtk::ImageType::LA_U16; break; - case OIIO::TypeDesc::HALF: info.type = dtk::ImageType::LA_F16; break; - case OIIO::TypeDesc::FLOAT: info.type = dtk::ImageType::LA_F32; break; + case OIIO::TypeDesc::UINT8: info.type = feather_tk::ImageType::LA_U8; break; + case OIIO::TypeDesc::UINT16: info.type = feather_tk::ImageType::LA_U16; break; + case OIIO::TypeDesc::HALF: info.type = feather_tk::ImageType::LA_F16; break; + case OIIO::TypeDesc::FLOAT: info.type = feather_tk::ImageType::LA_F32; break; } break; case 3: switch (spec.format.basetype) { - case OIIO::TypeDesc::UINT8: info.type = dtk::ImageType::RGB_U8; break; - case OIIO::TypeDesc::UINT16: info.type = dtk::ImageType::RGB_U16; break; - case OIIO::TypeDesc::HALF: info.type = dtk::ImageType::RGB_F16; break; - case OIIO::TypeDesc::FLOAT: info.type = dtk::ImageType::RGB_F32; break; + case OIIO::TypeDesc::UINT8: info.type = feather_tk::ImageType::RGB_U8; break; + case OIIO::TypeDesc::UINT16: info.type = feather_tk::ImageType::RGB_U16; break; + case OIIO::TypeDesc::HALF: info.type = feather_tk::ImageType::RGB_F16; break; + case OIIO::TypeDesc::FLOAT: info.type = feather_tk::ImageType::RGB_F32; break; } break; default: switch (spec.format.basetype) { - case OIIO::TypeDesc::UINT8: info.type = dtk::ImageType::RGBA_U8; break; - case OIIO::TypeDesc::UINT16: info.type = dtk::ImageType::RGBA_U16; break; - case OIIO::TypeDesc::HALF: info.type = dtk::ImageType::RGBA_F16; break; - case OIIO::TypeDesc::FLOAT: info.type = dtk::ImageType::RGBA_F32; break; + case OIIO::TypeDesc::UINT8: info.type = feather_tk::ImageType::RGBA_U8; break; + case OIIO::TypeDesc::UINT16: info.type = feather_tk::ImageType::RGBA_U16; break; + case OIIO::TypeDesc::HALF: info.type = feather_tk::ImageType::RGBA_F16; break; + case OIIO::TypeDesc::FLOAT: info.type = feather_tk::ImageType::RGBA_F32; break; } break; } @@ -310,7 +310,7 @@ namespace toucan if (info.isValid()) { - thumbnail = dtk::Image::create(info); + thumbnail = feather_tk::Image::create(info); auto resizedBuf = OIIO::ImageBufAlgo::resize( buf, "", diff --git a/lib/toucanView/ThumbnailGenerator.h b/lib/toucanView/ThumbnailGenerator.h index b9719ff..18d732d 100644 --- a/lib/toucanView/ThumbnailGenerator.h +++ b/lib/toucanView/ThumbnailGenerator.h @@ -7,8 +7,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -31,7 +31,7 @@ namespace toucan uint64_t id = 0; OTIO_NS::RationalTime time; int height = 0; - std::future > future; + std::future > future; }; //! Thumbnail generator. @@ -39,7 +39,7 @@ namespace toucan { public: ThumbnailGenerator( - const std::shared_ptr&, + const std::shared_ptr&, const std::filesystem::path&, const std::shared_ptr&, const std::shared_ptr&); @@ -76,7 +76,7 @@ namespace toucan const std::shared_ptr&, const OTIO_NS::MediaReference*); - std::shared_ptr _logSystem; + std::shared_ptr _logSystem; std::filesystem::path _path; std::shared_ptr _timelineWrapper; std::shared_ptr _host; @@ -96,7 +96,7 @@ namespace toucan const OTIO_NS::MediaReference* ref = nullptr; OTIO_NS::RationalTime time; int height = 0; - std::promise > promise; + std::promise > promise; }; uint64_t _requestId = 0; diff --git a/lib/toucanView/ThumbnailsWidget.cpp b/lib/toucanView/ThumbnailsWidget.cpp index ceb31b0..4825911 100644 --- a/lib/toucanView/ThumbnailsWidget.cpp +++ b/lib/toucanView/ThumbnailsWidget.cpp @@ -6,15 +6,15 @@ #include #include -#include +#include namespace toucan { void ThumbnailsWidget::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const OTIO_NS::SerializableObject::Retainer& ref, const std::shared_ptr& thumbnailGenerator, - const std::shared_ptr > >& thumbnailCache, + const std::shared_ptr > >& thumbnailCache, const OTIO_NS::TimeRange& timeRange, const std::shared_ptr& parent) { @@ -29,10 +29,10 @@ namespace toucan {} std::shared_ptr ThumbnailsWidget::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const OTIO_NS::SerializableObject::Retainer& ref, const std::shared_ptr& thumbnailGenerator, - const std::shared_ptr > >& thumbnailCache, + const std::shared_ptr > >& thumbnailCache, const OTIO_NS::TimeRange& timeRange, const std::shared_ptr& parent) { @@ -44,7 +44,7 @@ namespace toucan void ThumbnailsWidget::tickEvent( bool parentsVisible, bool parentsEnabled, - const dtk::TickEvent& event) + const feather_tk::TickEvent& event) { ITimeWidget::tickEvent(parentsVisible, parentsEnabled, event); if (_thumbnailAspectRequest.valid() && @@ -71,7 +71,7 @@ namespace toucan } } - void ThumbnailsWidget::sizeHintEvent(const dtk::SizeHintEvent& event) + void ThumbnailsWidget::sizeHintEvent(const feather_tk::SizeHintEvent& event) { ITimeWidget::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -79,7 +79,7 @@ namespace toucan { _size.init = false; _size.displayScale = event.displayScale; - _size.thumbnailHeight = 2 * event.style->getSizeRole(dtk::SizeRole::SwatchLarge, event.displayScale); + _size.thumbnailHeight = 2 * event.style->getSizeRole(feather_tk::SizeRole::SwatchLarge, event.displayScale); std::vector ids; for (const auto& request : _thumbnailRequests) { @@ -88,32 +88,32 @@ namespace toucan _thumbnailRequests.clear(); _thumbnailGenerator->cancelThumbnails(ids); } - _setSizeHint(dtk::Size2I(0, _size.thumbnailHeight)); + _setSizeHint(feather_tk::Size2I(0, _size.thumbnailHeight)); } void ThumbnailsWidget::drawEvent( - const dtk::Box2I& drawRect, - const dtk::DrawEvent& event) + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent& event) { ITimeWidget::drawEvent(drawRect, event); - const dtk::Box2I& g = getGeometry(); + const feather_tk::Box2I& g = getGeometry(); const int thumbnailWidth = _size.thumbnailHeight * _thumbnailAspect; const int y = g.min.y; for (int x = g.min.x; x < g.max.x && thumbnailWidth > 0; x += thumbnailWidth) { - const dtk::Box2I g2(x, y, thumbnailWidth, _size.thumbnailHeight); - if (dtk::intersects(g2, drawRect)) + const feather_tk::Box2I g2(x, y, thumbnailWidth, _size.thumbnailHeight); + if (feather_tk::intersects(g2, drawRect)) { const OTIO_NS::RationalTime t = posToTime(x); - std::shared_ptr image; + std::shared_ptr image; const std::string cacheKey = getThumbnailCacheKey(_ref, t, _size.thumbnailHeight); if (_thumbnailCache->get(cacheKey, image)) { if (image) { - const dtk::Box2I g3(x, y, image->getWidth(), image->getHeight()); - event.render->drawRect(g3, dtk::Color4F(0.F, 0.F, 0.F)); + const feather_tk::Box2I g3(x, y, image->getWidth(), image->getHeight()); + event.render->drawRect(g3, feather_tk::Color4F(0.F, 0.F, 0.F)); event.render->drawImage(image, g3); } } @@ -142,8 +142,8 @@ namespace toucan while (i != _thumbnailRequests.end()) { const int x = timeToPos(i->time); - const dtk::Box2I g2(x, y, thumbnailWidth, _size.thumbnailHeight); - if (!dtk::intersects(g2, drawRect)) + const feather_tk::Box2I g2(x, y, thumbnailWidth, _size.thumbnailHeight); + if (!feather_tk::intersects(g2, drawRect)) { cancel.push_back(i->id); i = _thumbnailRequests.erase(i); diff --git a/lib/toucanView/ThumbnailsWidget.h b/lib/toucanView/ThumbnailsWidget.h index 1084e8d..1d8cbfb 100644 --- a/lib/toucanView/ThumbnailsWidget.h +++ b/lib/toucanView/ThumbnailsWidget.h @@ -15,10 +15,10 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const OTIO_NS::SerializableObject::Retainer&, const std::shared_ptr&, - const std::shared_ptr > >&, + const std::shared_ptr > >&, const OTIO_NS::TimeRange&, const std::shared_ptr& parent); @@ -27,25 +27,25 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const OTIO_NS::SerializableObject::Retainer&, const std::shared_ptr&, - const std::shared_ptr > >&, + const std::shared_ptr > >&, const OTIO_NS::TimeRange&, const std::shared_ptr& parent = nullptr); void tickEvent( bool parentsVisible, bool parentsEnabled, - const dtk::TickEvent&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; + const feather_tk::TickEvent&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; private: OTIO_NS::SerializableObject::Retainer _ref; float _thumbnailAspect = 0.F; std::shared_ptr _thumbnailGenerator; - std::shared_ptr > > _thumbnailCache; + std::shared_ptr > > _thumbnailCache; std::future _thumbnailAspectRequest; std::list _thumbnailRequests; diff --git a/lib/toucanView/TimeLayout.cpp b/lib/toucanView/TimeLayout.cpp index a3a37b4..ca650bb 100644 --- a/lib/toucanView/TimeLayout.cpp +++ b/lib/toucanView/TimeLayout.cpp @@ -6,12 +6,12 @@ namespace toucan { void ITimeWidget::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const OTIO_NS::TimeRange& timeRange, const std::string& objectName, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::IWidget::_init(context, objectName, parent); + feather_tk::IWidget::_init(context, objectName, parent); _timeRange = timeRange; } @@ -51,7 +51,7 @@ namespace toucan OTIO_NS::RationalTime ITimeWidget::posToTime(double value) const { OTIO_NS::RationalTime out; - const dtk::Box2I& g = getGeometry(); + const feather_tk::Box2I& g = getGeometry(); if (g.w() > 0) { const double n = (value - g.min.x) / static_cast(g.w()); @@ -61,7 +61,7 @@ namespace toucan _timeRange.duration().value() * n, _timeRange.duration().rate())). round(); - out = dtk::clamp( + out = feather_tk::clamp( out, _timeRange.start_time(), _timeRange.end_time_inclusive()); @@ -72,7 +72,7 @@ namespace toucan int ITimeWidget::timeToPos(const OTIO_NS::RationalTime& value) const { int out = 0; - const dtk::Box2I& g = getGeometry(); + const feather_tk::Box2I& g = getGeometry(); if (_timeRange.duration().value() > 0.0) { const OTIO_NS::RationalTime t = value - _timeRange.start_time(); @@ -83,9 +83,9 @@ namespace toucan } void TimeLayout::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const OTIO_NS::TimeRange& timeRange, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { ITimeWidget::_init(context, timeRange, "toucan::TimeLayout", parent); } @@ -94,16 +94,16 @@ namespace toucan {} std::shared_ptr TimeLayout::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const OTIO_NS::TimeRange& timeRange, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new TimeLayout); out->_init(context, timeRange, parent); return out; } - void TimeLayout::setGeometry(const dtk::Box2I& value) + void TimeLayout::setGeometry(const feather_tk::Box2I& value) { ITimeWidget::setGeometry(value); for (const auto& child : getChildren()) @@ -113,8 +113,8 @@ namespace toucan const OTIO_NS::TimeRange& timeRange = timeWidget->getTimeRange(); const int t0 = timeToPos(timeRange.start_time()); const int t1 = timeToPos(timeRange.end_time_exclusive()); - const dtk::Size2I& childSizeHint = child->getSizeHint(); - child->setGeometry(dtk::Box2I( + const feather_tk::Size2I& childSizeHint = child->getSizeHint(); + child->setGeometry(feather_tk::Box2I( t0, value.min.y, std::max(t1 - t0, timeWidget->getMinWidth()), @@ -123,15 +123,15 @@ namespace toucan } } - void TimeLayout::sizeHintEvent(const dtk::SizeHintEvent& event) + void TimeLayout::sizeHintEvent(const feather_tk::SizeHintEvent& event) { ITimeWidget::sizeHintEvent(event); - dtk::Size2I sizeHint; + feather_tk::Size2I sizeHint; for (const auto& child : getChildren()) { if (auto timeWidget = std::dynamic_pointer_cast(child)) { - const dtk::Size2I& childSizeHint = timeWidget->getSizeHint(); + const feather_tk::Size2I& childSizeHint = timeWidget->getSizeHint(); sizeHint.h = std::max(sizeHint.h, childSizeHint.h); } } @@ -140,9 +140,9 @@ namespace toucan } void TimeStackLayout::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const OTIO_NS::TimeRange& timeRange, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { ITimeWidget::_init(context, timeRange, "toucan::TimeStackLayout", parent); } @@ -151,16 +151,16 @@ namespace toucan {} std::shared_ptr TimeStackLayout::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const OTIO_NS::TimeRange& timeRange, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new TimeStackLayout); out->_init(context, timeRange, parent); return out; } - void TimeStackLayout::setGeometry(const dtk::Box2I& value) + void TimeStackLayout::setGeometry(const feather_tk::Box2I& value) { ITimeWidget::setGeometry(value); int y = value.min.y; @@ -171,14 +171,14 @@ namespace toucan const OTIO_NS::TimeRange& timeRange = timeWidget->getTimeRange(); const double t0 = timeToPos(timeRange.start_time()); const double t1 = timeToPos(timeRange.end_time_exclusive()); - const dtk::Size2I& childSizeHint = child->getSizeHint(); - child->setGeometry(dtk::Box2I(t0, y, t1 - t0, childSizeHint.h)); + const feather_tk::Size2I& childSizeHint = child->getSizeHint(); + child->setGeometry(feather_tk::Box2I(t0, y, t1 - t0, childSizeHint.h)); y += childSizeHint.h + _size.spacing; }; } } - void TimeStackLayout::sizeHintEvent(const dtk::SizeHintEvent& event) + void TimeStackLayout::sizeHintEvent(const feather_tk::SizeHintEvent& event) { ITimeWidget::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -186,10 +186,10 @@ namespace toucan { _size.init = false; _size.displayScale = event.displayScale; - _size.spacing = event.style->getSizeRole(dtk::SizeRole::SpacingTool, event.displayScale); + _size.spacing = event.style->getSizeRole(feather_tk::SizeRole::SpacingTool, event.displayScale); } - dtk::Size2I sizeHint; + feather_tk::Size2I sizeHint; const auto& children = getChildren(); if (!children.empty()) { @@ -197,7 +197,7 @@ namespace toucan { if (auto timeWidget = std::dynamic_pointer_cast(child)) { - const dtk::Size2I& childSizeHint = timeWidget->getSizeHint(); + const feather_tk::Size2I& childSizeHint = timeWidget->getSizeHint(); sizeHint.h += childSizeHint.h; } } diff --git a/lib/toucanView/TimeLayout.h b/lib/toucanView/TimeLayout.h index 95ae29b..eeaa323 100644 --- a/lib/toucanView/TimeLayout.h +++ b/lib/toucanView/TimeLayout.h @@ -3,18 +3,18 @@ #pragma once -#include +#include #include namespace toucan { //! Base class for widgets in a time layout. - class ITimeWidget : public dtk::IWidget + class ITimeWidget : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const OTIO_NS::TimeRange&, const std::string& objectName, const std::shared_ptr& parent); @@ -51,7 +51,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const OTIO_NS::TimeRange&, const std::shared_ptr& parent); @@ -60,12 +60,12 @@ namespace toucan //! Create a new layout. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const OTIO_NS::TimeRange&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; }; //! Time stack layout. @@ -73,7 +73,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const OTIO_NS::TimeRange&, const std::shared_ptr& parent); @@ -82,12 +82,12 @@ namespace toucan //! Create a new layout. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const OTIO_NS::TimeRange&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: struct SizeData diff --git a/lib/toucanView/TimeMenu.cpp b/lib/toucanView/TimeMenu.cpp index efb2468..7a7ee90 100644 --- a/lib/toucanView/TimeMenu.cpp +++ b/lib/toucanView/TimeMenu.cpp @@ -7,21 +7,21 @@ #include "FilesModel.h" #include "PlaybackModel.h" -#include +#include namespace toucan { void TimeMenu::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::Menu::_init(context, parent); + feather_tk::Menu::_init(context, parent); - _actions["Time/FrameStart"] = std::make_shared( + _actions["Time/FrameStart"] = feather_tk::Action::create( "Start Frame", "FrameStart", - dtk::Key::Up, + feather_tk::Key::Up, 0, [this] { @@ -32,12 +32,12 @@ namespace toucan _file->getTimeline()); } }); - addItem(_actions["Time/FrameStart"]); + addAction(_actions["Time/FrameStart"]); - _actions["Time/FramePrev"] = std::make_shared( + _actions["Time/FramePrev"] = feather_tk::Action::create( "Previous Frame", "FramePrev", - dtk::Key::Left, + feather_tk::Key::Left, 0, [this] { @@ -48,12 +48,12 @@ namespace toucan _file->getTimeline()); } }); - addItem(_actions["Time/FramePrev"]); + addAction(_actions["Time/FramePrev"]); - _actions["Time/FramePrevX10"] = std::make_shared( + _actions["Time/FramePrevX10"] = feather_tk::Action::create( "Previous Frame X10", - dtk::Key::Left, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::Left, + static_cast(feather_tk::KeyModifier::Shift), [this] { if (_file) @@ -63,12 +63,12 @@ namespace toucan _file->getTimeline()); } }); - addItem(_actions["Time/FramePrevX10"]); + addAction(_actions["Time/FramePrevX10"]); - _actions["Time/FramePrevX100"] = std::make_shared( + _actions["Time/FramePrevX100"] = feather_tk::Action::create( "Previous Frame X100", - dtk::Key::Left, - static_cast(dtk::commandKeyModifier), + feather_tk::Key::Left, + static_cast(feather_tk::commandKeyModifier), [this] { if (_file) @@ -78,12 +78,12 @@ namespace toucan _file->getTimeline()); } }); - addItem(_actions["Time/FramePrevX100"]); + addAction(_actions["Time/FramePrevX100"]); - _actions["Time/FrameNext"] = std::make_shared( + _actions["Time/FrameNext"] = feather_tk::Action::create( "Next Frame", "FrameNext", - dtk::Key::Right, + feather_tk::Key::Right, 0, [this] { @@ -94,12 +94,12 @@ namespace toucan _file->getTimeline()); } }); - addItem(_actions["Time/FrameNext"]); + addAction(_actions["Time/FrameNext"]); - _actions["Time/FrameNextX10"] = std::make_shared( + _actions["Time/FrameNextX10"] = feather_tk::Action::create( "Next Frame X10", - dtk::Key::Right, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::Right, + static_cast(feather_tk::KeyModifier::Shift), [this] { if (_file) @@ -109,12 +109,12 @@ namespace toucan _file->getTimeline()); } }); - addItem(_actions["Time/FrameNextX10"]); + addAction(_actions["Time/FrameNextX10"]); - _actions["Time/FrameNextX100"] = std::make_shared( + _actions["Time/FrameNextX100"] = feather_tk::Action::create( "Next Frame X100", - dtk::Key::Right, - static_cast(dtk::commandKeyModifier), + feather_tk::Key::Right, + static_cast(feather_tk::commandKeyModifier), [this] { if (_file) @@ -124,12 +124,12 @@ namespace toucan _file->getTimeline()); } }); - addItem(_actions["Time/FrameNextX100"]); + addAction(_actions["Time/FrameNextX100"]); - _actions["Time/FrameEnd"] = std::make_shared( + _actions["Time/FrameEnd"] = feather_tk::Action::create( "End Frame", "FrameEnd", - dtk::Key::Down, + feather_tk::Key::Down, 0, [this] { @@ -140,14 +140,14 @@ namespace toucan _file->getTimeline()); } }); - addItem(_actions["Time/FrameEnd"]); + addAction(_actions["Time/FrameEnd"]); addDivider(); - _actions["Time/ClipNext"] = std::make_shared( + _actions["Time/ClipNext"] = feather_tk::Action::create( "Next Clip", - dtk::Key::Right, - static_cast(dtk::KeyModifier::Alt), + feather_tk::Key::Right, + static_cast(feather_tk::KeyModifier::Alt), [this] { if (_file) @@ -157,12 +157,12 @@ namespace toucan _file->getTimeline()); } }); - addItem(_actions["Time/ClipNext"]); + addAction(_actions["Time/ClipNext"]); - _actions["Time/ClipPrev"] = std::make_shared( + _actions["Time/ClipPrev"] = feather_tk::Action::create( "Previous Clip", - dtk::Key::Left, - static_cast(dtk::KeyModifier::Alt), + feather_tk::Key::Left, + static_cast(feather_tk::KeyModifier::Alt), [this] { if (_file) @@ -172,13 +172,13 @@ namespace toucan _file->getTimeline()); } }); - addItem(_actions["Time/ClipPrev"]); + addAction(_actions["Time/ClipPrev"]); addDivider(); - _actions["Time/InPointSet"] = std::make_shared( + _actions["Time/InPointSet"] = feather_tk::Action::create( "Set In Point", - dtk::Key::I, + feather_tk::Key::I, 0, [this] { @@ -188,12 +188,12 @@ namespace toucan _file->getPlaybackModel()->getCurrentTime()); } }); - addItem(_actions["Time/InPointSet"]); + addAction(_actions["Time/InPointSet"]); - _actions["Time/InPointReset"] = std::make_shared( + _actions["Time/InPointReset"] = feather_tk::Action::create( "Reset In Point", - dtk::Key::I, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::I, + static_cast(feather_tk::KeyModifier::Shift), [this] { if (_file) @@ -201,11 +201,11 @@ namespace toucan _file->getPlaybackModel()->resetInPoint(); } }); - addItem(_actions["Time/InPointReset"]); + addAction(_actions["Time/InPointReset"]); - _actions["Time/OutPointSet"] = std::make_shared( + _actions["Time/OutPointSet"] = feather_tk::Action::create( "Set Out Point", - dtk::Key::O, + feather_tk::Key::O, 0, [this] { @@ -215,12 +215,12 @@ namespace toucan _file->getPlaybackModel()->getCurrentTime()); } }); - addItem(_actions["Time/OutPointSet"]); + addAction(_actions["Time/OutPointSet"]); - _actions["Time/OutPointReset"] = std::make_shared( + _actions["Time/OutPointReset"] = feather_tk::Action::create( "Reset Out Point", - dtk::Key::O, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::O, + static_cast(feather_tk::KeyModifier::Shift), [this] { if (_file) @@ -228,12 +228,12 @@ namespace toucan _file->getPlaybackModel()->resetOutPoint(); } }); - addItem(_actions["Time/OutPointReset"]); + addAction(_actions["Time/OutPointReset"]); - _actions["Time/InOutPointReset"] = std::make_shared( + _actions["Time/InOutPointReset"] = feather_tk::Action::create( "Reset In/Out Points", - dtk::Key::P, - static_cast(dtk::KeyModifier::Shift), + feather_tk::Key::P, + static_cast(feather_tk::KeyModifier::Shift), [this] { if (_file) @@ -241,12 +241,12 @@ namespace toucan _file->getPlaybackModel()->resetInOutPoints(); } }); - addItem(_actions["Time/InOutPointReset"]); + addAction(_actions["Time/InOutPointReset"]); - _actions["Time/InOutPointSelection"] = std::make_shared( + _actions["Time/InOutPointSelection"] = feather_tk::Action::create( "Set In/Out Points To Selection", - dtk::Key::P, - static_cast(dtk::KeyModifier::Shift) | static_cast(dtk::commandKeyModifier), + feather_tk::Key::P, + static_cast(feather_tk::KeyModifier::Shift) | static_cast(feather_tk::commandKeyModifier), [this] { if (_file) @@ -268,30 +268,30 @@ namespace toucan } } }); - addItem(_actions["Time/InOutPointSelection"]); + addAction(_actions["Time/InOutPointSelection"]); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { _file = file; if (_file) { - _timeRangeObserver = dtk::ValueObserver::create( + _timeRangeObserver = feather_tk::ValueObserver::create( _file->getPlaybackModel()->observeTimeRange(), [this](const OTIO_NS::TimeRange& value) { _timeRange = value; _menuUpdate(); }); - _inOutRangeObserver = dtk::ValueObserver::create( + _inOutRangeObserver = feather_tk::ValueObserver::create( _file->getPlaybackModel()->observeInOutRange(), [this](const OTIO_NS::TimeRange& value) { _inOutRange = value; _menuUpdate(); }); - _selectionObserver = dtk::ListObserver::create( + _selectionObserver = feather_tk::ListObserver::create( _file->getSelectionModel()->observeSelection(), [this](const std::vector& value) { @@ -312,16 +312,16 @@ namespace toucan {} std::shared_ptr TimeMenu::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new TimeMenu); out->_init(context, app, parent); return out; } - const std::map >& TimeMenu::getActions() const + const std::map >& TimeMenu::getActions() const { return _actions; } @@ -329,21 +329,21 @@ namespace toucan void TimeMenu::_menuUpdate() { const bool file = _file.get(); - setItemEnabled(_actions["Time/FrameStart"], file); - setItemEnabled(_actions["Time/FramePrev"], file); - setItemEnabled(_actions["Time/FramePrevX10"], file); - setItemEnabled(_actions["Time/FramePrevX100"], file); - setItemEnabled(_actions["Time/FrameNext"], file); - setItemEnabled(_actions["Time/FrameNextX10"], file); - setItemEnabled(_actions["Time/FrameNextX100"], file); - setItemEnabled(_actions["Time/FrameEnd"], file); - setItemEnabled(_actions["Time/ClipPrev"], file); - setItemEnabled(_actions["Time/ClipNext"], file); - setItemEnabled(_actions["Time/InPointSet"], file); - setItemEnabled(_actions["Time/OutPointSet"], file); - setItemEnabled(_actions["Time/InPointReset"], file && _inOutRange != _timeRange); - setItemEnabled(_actions["Time/OutPointReset"], file && _inOutRange != _timeRange); - setItemEnabled(_actions["Time/InOutPointReset"], file && _inOutRange != _timeRange); - setItemEnabled(_actions["Time/InOutPointSelection"], file && _selection); + setEnabled(_actions["Time/FrameStart"], file); + setEnabled(_actions["Time/FramePrev"], file); + setEnabled(_actions["Time/FramePrevX10"], file); + setEnabled(_actions["Time/FramePrevX100"], file); + setEnabled(_actions["Time/FrameNext"], file); + setEnabled(_actions["Time/FrameNextX10"], file); + setEnabled(_actions["Time/FrameNextX100"], file); + setEnabled(_actions["Time/FrameEnd"], file); + setEnabled(_actions["Time/ClipPrev"], file); + setEnabled(_actions["Time/ClipNext"], file); + setEnabled(_actions["Time/InPointSet"], file); + setEnabled(_actions["Time/OutPointSet"], file); + setEnabled(_actions["Time/InPointReset"], file && _inOutRange != _timeRange); + setEnabled(_actions["Time/OutPointReset"], file && _inOutRange != _timeRange); + setEnabled(_actions["Time/InOutPointReset"], file && _inOutRange != _timeRange); + setEnabled(_actions["Time/InOutPointSelection"], file && _selection); } } diff --git a/lib/toucanView/TimeMenu.h b/lib/toucanView/TimeMenu.h index b21065f..54e8c30 100644 --- a/lib/toucanView/TimeMenu.h +++ b/lib/toucanView/TimeMenu.h @@ -5,7 +5,7 @@ #include -#include +#include #include @@ -17,11 +17,11 @@ namespace toucan class File; //! Time menu. - class TimeMenu : public dtk::Menu + class TimeMenu : public feather_tk::Menu { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -30,12 +30,12 @@ namespace toucan //! Create a new menu. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Get the actions. - const std::map >& getActions() const; + const std::map >& getActions() const; private: void _menuUpdate(); @@ -45,12 +45,12 @@ namespace toucan OTIO_NS::TimeRange _inOutRange; bool _selection = false; - std::map > _actions; + std::map > _actions; - std::shared_ptr > > _fileObserver; - std::shared_ptr > _timeRangeObserver; - std::shared_ptr > _inOutRangeObserver; - std::shared_ptr > _selectionObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > _timeRangeObserver; + std::shared_ptr > _inOutRangeObserver; + std::shared_ptr > _selectionObserver; }; } diff --git a/lib/toucanView/TimeUnitsModel.cpp b/lib/toucanView/TimeUnitsModel.cpp index c21e821..8c26f95 100644 --- a/lib/toucanView/TimeUnitsModel.cpp +++ b/lib/toucanView/TimeUnitsModel.cpp @@ -3,10 +3,10 @@ #include "TimeUnitsModel.h" -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -15,7 +15,7 @@ namespace toucan { - DTK_ENUM_IMPL( + FEATHER_TK_ENUM_IMPL( TimeUnits, "Timecode", "Frames", @@ -70,22 +70,23 @@ namespace toucan std::string toString(const OTIO_NS::TimeRange& timeRange, TimeUnits units) { - return dtk::Format("{0} - {1} : {2} @ {3}"). + return feather_tk::Format("{0} - {1} : {2} @ {3}"). arg(toString(timeRange.start_time(), units)). arg(toString(timeRange.end_time_inclusive(), units)). arg(toString(timeRange.duration(), units)). arg(timeRange.duration().rate()); } - TimeUnitsModel::TimeUnitsModel(const std::shared_ptr& context) + TimeUnitsModel::TimeUnitsModel( + const std::shared_ptr& context, + const std::shared_ptr& settings) : + _settings(settings) { - _context = context; - TimeUnits value = TimeUnits::Timecode; try { - auto settings = context->getSystem(); - const auto json = std::any_cast(settings->get("TimeUnits")); + nlohmann::json json; + settings->get("/TimeUnits", json); auto i = json.find("Units"); if (i != json.end() && i->is_string()) { @@ -96,7 +97,7 @@ namespace toucan catch (const std::exception&) {} - _timeUnits = dtk::ObservableValue::create(value); + _timeUnits = feather_tk::ObservableValue::create(value); } TimeUnitsModel::~TimeUnitsModel() @@ -105,9 +106,7 @@ namespace toucan std::stringstream ss; ss << _timeUnits->get(); json["Units"] = ss.str(); - auto context = _context.lock(); - auto settings = context->getSystem(); - settings->set("TimeUnits", json); + _settings->set("/TimeUnits", json); } TimeUnits TimeUnitsModel::getTimeUnits() const @@ -115,7 +114,7 @@ namespace toucan return _timeUnits->get(); } - std::shared_ptr > TimeUnitsModel::observeTimeUnits() const + std::shared_ptr > TimeUnitsModel::observeTimeUnits() const { return _timeUnits; } diff --git a/lib/toucanView/TimeUnitsModel.h b/lib/toucanView/TimeUnitsModel.h index 945ab9e..e9c2cfb 100644 --- a/lib/toucanView/TimeUnitsModel.h +++ b/lib/toucanView/TimeUnitsModel.h @@ -3,8 +3,9 @@ #pragma once -#include -#include +#include +#include +#include #include @@ -20,7 +21,7 @@ namespace toucan Count, First = Timecode }; - DTK_ENUM(TimeUnits); + FEATHER_TK_ENUM(TimeUnits); //! Convert a time to a string. std::string toString(const OTIO_NS::RationalTime&, TimeUnits); @@ -35,7 +36,9 @@ namespace toucan class TimeUnitsModel : public std::enable_shared_from_this { public: - TimeUnitsModel(const std::shared_ptr&); + TimeUnitsModel( + const std::shared_ptr&, + const std::shared_ptr&); virtual ~TimeUnitsModel(); @@ -43,13 +46,13 @@ namespace toucan TimeUnits getTimeUnits() const; //! Observe the time units. - std::shared_ptr > observeTimeUnits() const; + std::shared_ptr > observeTimeUnits() const; //! Set the time units. void setTimeUnits(TimeUnits); private: - std::weak_ptr _context; - std::shared_ptr > _timeUnits; + std::shared_ptr _settings; + std::shared_ptr > _timeUnits; }; } diff --git a/lib/toucanView/TimeWidgets.cpp b/lib/toucanView/TimeWidgets.cpp index c648159..200eb8f 100644 --- a/lib/toucanView/TimeWidgets.cpp +++ b/lib/toucanView/TimeWidgets.cpp @@ -3,40 +3,40 @@ #include "TimeWidgets.h" -#include +#include #include namespace toucan { void FrameButtons::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& parent) { IWidget::_init(context, "toucan::FrameButtons", parent); - _layout = dtk::HorizontalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingTool); + _layout = feather_tk::HorizontalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingTool); - auto startButton = dtk::ToolButton::create(context, _layout); + auto startButton = feather_tk::ToolButton::create(context, _layout); startButton->setIcon("FrameStart"); startButton->setTooltip("Go to the start frame"); - auto prevButton = dtk::ToolButton::create(context, _layout); + auto prevButton = feather_tk::ToolButton::create(context, _layout); prevButton->setIcon("FramePrev"); prevButton->setRepeatClick(true); prevButton->setTooltip("Go to the previous frame"); - auto nextButton = dtk::ToolButton::create(context, _layout); + auto nextButton = feather_tk::ToolButton::create(context, _layout); nextButton->setIcon("FrameNext"); nextButton->setRepeatClick(true); nextButton->setTooltip("Go to the next frame"); - auto endButton = dtk::ToolButton::create(context, _layout); + auto endButton = feather_tk::ToolButton::create(context, _layout); endButton->setIcon("FrameEnd"); endButton->setTooltip("Go to the end frame"); - _buttonGroup = dtk::ButtonGroup::create(context, dtk::ButtonGroupType::Click); + _buttonGroup = feather_tk::ButtonGroup::create(context, feather_tk::ButtonGroupType::Click); _buttonGroup->addButton(startButton); _buttonGroup->addButton(prevButton); _buttonGroup->addButton(nextButton); @@ -56,7 +56,7 @@ namespace toucan {} std::shared_ptr FrameButtons::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& parent) { auto out = std::shared_ptr(new FrameButtons); @@ -69,40 +69,40 @@ namespace toucan _callback = value; } - void FrameButtons::setGeometry(const dtk::Box2I& value) + void FrameButtons::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void FrameButtons::sizeHintEvent(const dtk::SizeHintEvent& value) + void FrameButtons::sizeHintEvent(const feather_tk::SizeHintEvent& value) { IWidget::sizeHintEvent(value); _setSizeHint(_layout->getSizeHint()); } void PlaybackButtons::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& parent) { IWidget::_init(context, "toucan::PlaybackButtons", parent); - _layout = dtk::HorizontalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingTool); + _layout = feather_tk::HorizontalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingTool); - auto reverseButton = dtk::ToolButton::create(context, _layout); + auto reverseButton = feather_tk::ToolButton::create(context, _layout); reverseButton->setIcon("PlaybackReverse"); reverseButton->setTooltip("Reverse playback"); - auto stopButton = dtk::ToolButton::create(context, _layout); + auto stopButton = feather_tk::ToolButton::create(context, _layout); stopButton->setIcon("PlaybackStop"); stopButton->setTooltip("Stop playback"); - auto forwardButton = dtk::ToolButton::create(context, _layout); + auto forwardButton = feather_tk::ToolButton::create(context, _layout); forwardButton->setIcon("PlaybackForward"); forwardButton->setTooltip("Forward playback"); - _buttonGroup = dtk::ButtonGroup::create(context, dtk::ButtonGroupType::Radio); + _buttonGroup = feather_tk::ButtonGroup::create(context, feather_tk::ButtonGroupType::Radio); _buttonGroup->addButton(stopButton); _buttonGroup->addButton(forwardButton); _buttonGroup->addButton(reverseButton); @@ -126,7 +126,7 @@ namespace toucan {} std::shared_ptr PlaybackButtons::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& parent) { auto out = std::shared_ptr(new PlaybackButtons); @@ -147,13 +147,13 @@ namespace toucan _callback = value; } - void PlaybackButtons::setGeometry(const dtk::Box2I& value) + void PlaybackButtons::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void PlaybackButtons::sizeHintEvent(const dtk::SizeHintEvent& value) + void PlaybackButtons::sizeHintEvent(const feather_tk::SizeHintEvent& value) { IWidget::sizeHintEvent(value); _setSizeHint(_layout->getSizeHint()); @@ -165,20 +165,20 @@ namespace toucan } void TimeEdit::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& timeUnitsModel, const std::shared_ptr& parent) { IWidget::_init(context, "toucan::TimeEdit", parent); - _layout = dtk::HorizontalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingTool); + _layout = feather_tk::HorizontalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingTool); - _lineEdit = dtk::LineEdit::create(context, _layout); - _lineEdit->setFontRole(dtk::FontRole::Mono); + _lineEdit = feather_tk::LineEdit::create(context, _layout); + _lineEdit->setFontRole(feather_tk::FontRole::Mono); _lineEdit->setFormat("00:00:00:00"); - _incButtons = dtk::IncButtons::create(context, _layout); + _incButtons = feather_tk::IncButtons::create(context, _layout); _timeUpdate(); @@ -202,7 +202,7 @@ namespace toucan _timeDec(); }); - _timeUnitsObserver = dtk::ValueObserver::create( + _timeUnitsObserver = feather_tk::ValueObserver::create( timeUnitsModel->observeTimeUnits(), [this](TimeUnits value) { @@ -215,9 +215,9 @@ namespace toucan {} std::shared_ptr TimeEdit::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& timeUnitsModel, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new TimeEdit); out->_init(context, timeUnitsModel, parent); @@ -246,19 +246,19 @@ namespace toucan _callback = value; } - void TimeEdit::setGeometry(const dtk::Box2I& value) + void TimeEdit::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void TimeEdit::sizeHintEvent(const dtk::SizeHintEvent& value) + void TimeEdit::sizeHintEvent(const feather_tk::SizeHintEvent& value) { IWidget::sizeHintEvent(value); _setSizeHint(_layout->getSizeHint()); } - void TimeEdit::keyPressEvent(dtk::KeyEvent& event) + void TimeEdit::keyPressEvent(feather_tk::KeyEvent& event) { if (_lineEdit->hasKeyFocus()) { @@ -266,21 +266,21 @@ namespace toucan { switch (event.key) { - case dtk::Key::Up: - case dtk::Key::Right: + case feather_tk::Key::Up: + case feather_tk::Key::Right: event.accept = true; _timeInc(); break; - case dtk::Key::Down: - case dtk::Key::Left: + case feather_tk::Key::Down: + case feather_tk::Key::Left: event.accept = true; _timeDec(); break; - case dtk::Key::PageUp: + case feather_tk::Key::PageUp: event.accept = true; _timeInc(_time.rate()); break; - case dtk::Key::PageDown: + case feather_tk::Key::PageDown: event.accept = true; _timeInc(-_time.rate()); break; @@ -294,7 +294,7 @@ namespace toucan } } - void TimeEdit::keyReleaseEvent(dtk::KeyEvent& event) + void TimeEdit::keyReleaseEvent(feather_tk::KeyEvent& event) { IWidget::keyReleaseEvent(event); event.accept = true; @@ -324,19 +324,19 @@ namespace toucan } void TimeLabel::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& timeUnitsModel, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IWidget::_init(context, "toucan::TimeLabel", parent); - _label = dtk::Label::create(context, shared_from_this()); - _label->setFontRole(dtk::FontRole::Mono); - _label->setMarginRole(dtk::SizeRole::MarginInside); + _label = feather_tk::Label::create(context, shared_from_this()); + _label->setFontRole(feather_tk::FontRole::Mono); + _label->setMarginRole(feather_tk::SizeRole::MarginInside); _timeUpdate(); - _timeUnitsObserver = dtk::ValueObserver::create( + _timeUnitsObserver = feather_tk::ValueObserver::create( timeUnitsModel->observeTimeUnits(), [this](TimeUnits value) { @@ -349,9 +349,9 @@ namespace toucan {} std::shared_ptr TimeLabel::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& timeUnitsModel, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new TimeLabel); out->_init(context, timeUnitsModel, parent); @@ -366,18 +366,18 @@ namespace toucan _timeUpdate(); } - void TimeLabel::setMarginRole(dtk::SizeRole value) + void TimeLabel::setMarginRole(feather_tk::SizeRole value) { _label->setMarginRole(value); } - void TimeLabel::setGeometry(const dtk::Box2I& value) + void TimeLabel::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _label->setGeometry(value); } - void TimeLabel::sizeHintEvent(const dtk::SizeHintEvent& value) + void TimeLabel::sizeHintEvent(const feather_tk::SizeHintEvent& value) { IWidget::sizeHintEvent(value); _setSizeHint(_label->getSizeHint()); diff --git a/lib/toucanView/TimeWidgets.h b/lib/toucanView/TimeWidgets.h index 0c6f3dc..8236e8e 100644 --- a/lib/toucanView/TimeWidgets.h +++ b/lib/toucanView/TimeWidgets.h @@ -6,22 +6,22 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include namespace toucan { //! Frame buttons. - class FrameButtons : public dtk::IWidget + class FrameButtons : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr& parent); public: @@ -29,27 +29,27 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Set the callback. void setCallback(const std::function&); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: std::function _callback; - std::shared_ptr _layout; - std::shared_ptr _buttonGroup; + std::shared_ptr _layout; + std::shared_ptr _buttonGroup; }; //! Playback buttons. - class PlaybackButtons : public dtk::IWidget + class PlaybackButtons : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr& parent); public: @@ -57,7 +57,7 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Set the playback. @@ -66,24 +66,24 @@ namespace toucan //! Set the callback. void setCallback(const std::function&); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: void _playbackUpdate(); Playback _playback = Playback::Stop; std::function _callback; - std::shared_ptr _layout; - std::shared_ptr _buttonGroup; + std::shared_ptr _layout; + std::shared_ptr _buttonGroup; }; //! Time edit. - class TimeEdit : public dtk::IWidget + class TimeEdit : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -92,7 +92,7 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); @@ -105,10 +105,10 @@ namespace toucan //! Set the callback. void setCallback(const std::function&); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void keyPressEvent(dtk::KeyEvent&) override; - void keyReleaseEvent(dtk::KeyEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void keyPressEvent(feather_tk::KeyEvent&) override; + void keyReleaseEvent(feather_tk::KeyEvent&) override; private: void _timeInc(int = 1); @@ -119,20 +119,20 @@ namespace toucan OTIO_NS::TimeRange _timeRange; TimeUnits _timeUnits = TimeUnits::First; - std::shared_ptr _layout; - std::shared_ptr _lineEdit; - std::shared_ptr _incButtons; + std::shared_ptr _layout; + std::shared_ptr _lineEdit; + std::shared_ptr _incButtons; std::function _callback; - std::shared_ptr > _timeUnitsObserver; + std::shared_ptr > _timeUnitsObserver; }; //! Time label. - class TimeLabel : public dtk::IWidget + class TimeLabel : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -141,7 +141,7 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); @@ -149,10 +149,10 @@ namespace toucan void setTime(const OTIO_NS::RationalTime&); //! Set the margin size role. - void setMarginRole(dtk::SizeRole); + void setMarginRole(feather_tk::SizeRole); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: void _timeUpdate(); @@ -160,9 +160,9 @@ namespace toucan OTIO_NS::RationalTime _time; TimeUnits _timeUnits = TimeUnits::First; - std::shared_ptr _label; + std::shared_ptr _label; - std::shared_ptr > _timeUnitsObserver; + std::shared_ptr > _timeUnitsObserver; }; } diff --git a/lib/toucanView/TimelineItem.cpp b/lib/toucanView/TimelineItem.cpp index 5ddcc72..5bc2b5d 100644 --- a/lib/toucanView/TimelineItem.cpp +++ b/lib/toucanView/TimelineItem.cpp @@ -8,12 +8,12 @@ #include "StackItem.h" #include "WindowModel.h" -#include +#include namespace toucan { void TimelineItem::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const std::shared_ptr& parent) { @@ -29,7 +29,7 @@ namespace toucan _setMousePressEnabled( true, 0, - 0 | static_cast(dtk::KeyModifier::Shift) | static_cast(dtk::commandKeyModifier)); + 0 | static_cast(feather_tk::KeyModifier::Shift) | static_cast(feather_tk::commandKeyModifier)); _timeline = data.file->getTimeline(); _timeRange = data.file->getTimelineWrapper()->getTimeRange(); @@ -44,14 +44,14 @@ namespace toucan _timeline, shared_from_this()); - _selectionObserver = dtk::ListObserver::create( + _selectionObserver = feather_tk::ListObserver::create( _selectionModel->observeSelection(), [this](const std::vector& selection) { _select(shared_from_this(), selection); }); - _thumbnailsObserver = dtk::ValueObserver::create( + _thumbnailsObserver = feather_tk::ValueObserver::create( data.app->getWindowModel()->observeThumbnails(), [this](bool value) { @@ -65,7 +65,7 @@ namespace toucan {} std::shared_ptr TimelineItem::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const std::shared_ptr& parent) { @@ -100,26 +100,26 @@ namespace toucan _setDrawUpdate(); } - void TimelineItem::setGeometry(const dtk::Box2I& value) + void TimelineItem::setGeometry(const feather_tk::Box2I& value) { IItem::setGeometry(value); - const dtk::Box2I& g = getGeometry(); + const feather_tk::Box2I& g = getGeometry(); const int timeHeight = _size.fontMetrics.lineHeight + _size.margin * 2; for (const auto& child : getChildren()) { - const dtk::Size2I& sizeHint = child->getSizeHint(); + const feather_tk::Size2I& sizeHint = child->getSizeHint(); int h = timeHeight; if (_thumbnails) { h += _size.thumbnailHeight; } - child->setGeometry(dtk::Box2I( + child->setGeometry(feather_tk::Box2I( g.min.x, g.min.y + h, sizeHint.w, sizeHint.h)); } - if (auto scrollArea = getParentT()) + if (auto scrollArea = getParentT()) { _size.scrollPos = scrollArea->getScrollPos(); } @@ -128,7 +128,7 @@ namespace toucan void TimelineItem::tickEvent( bool parentsVisible, bool parentsEnabled, - const dtk::TickEvent& event) + const feather_tk::TickEvent& event) { IItem::tickEvent(parentsVisible, parentsEnabled, event); auto i = _thumbnailRequests.begin(); @@ -149,7 +149,7 @@ namespace toucan } } - void TimelineItem::sizeHintEvent(const dtk::SizeHintEvent& event) + void TimelineItem::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IItem::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -157,11 +157,11 @@ namespace toucan { _size.init = false; _size.displayScale = event.displayScale; - _size.margin = event.style->getSizeRole(dtk::SizeRole::MarginInside, event.displayScale); - _size.border = event.style->getSizeRole(dtk::SizeRole::Border, event.displayScale); - _size.handle = event.style->getSizeRole(dtk::SizeRole::Handle, event.displayScale); - _size.thumbnailHeight = 2 * event.style->getSizeRole(dtk::SizeRole::SwatchLarge, event.displayScale); - _size.fontInfo = event.style->getFontRole(dtk::FontRole::Mono, event.displayScale); + _size.margin = event.style->getSizeRole(feather_tk::SizeRole::MarginInside, event.displayScale); + _size.border = event.style->getSizeRole(feather_tk::SizeRole::Border, event.displayScale); + _size.handle = event.style->getSizeRole(feather_tk::SizeRole::Handle, event.displayScale); + _size.thumbnailHeight = 2 * event.style->getSizeRole(feather_tk::SizeRole::SwatchLarge, event.displayScale); + _size.fontInfo = event.style->getFontRole(feather_tk::FontRole::Mono, event.displayScale); _size.fontMetrics = event.fontSystem->getMetrics(_size.fontInfo); std::vector ids; for (const auto& request : _thumbnailRequests) @@ -177,7 +177,7 @@ namespace toucan { childSizeHint = std::max(childSizeHint, child->getSizeHint().h); } - dtk::Size2I sizeHint( + feather_tk::Size2I sizeHint( _timeRange.duration().rescaled_to(1.0).value() * _scale, _size.fontMetrics.lineHeight + _size.margin * 2); if (_thumbnails) @@ -188,29 +188,29 @@ namespace toucan _setSizeHint(sizeHint); } - void TimelineItem::drawEvent(const dtk::Box2I& drawRect, const dtk::DrawEvent& event) + void TimelineItem::drawEvent(const feather_tk::Box2I& drawRect, const feather_tk::DrawEvent& event) { IItem::drawEvent(drawRect, event); - const dtk::Box2I& g = getGeometry(); + const feather_tk::Box2I& g = getGeometry(); const int thumbnailWidth = _size.thumbnailHeight * _thumbnailGenerator->getAspect(); const int y = g.min.y + _size.fontMetrics.lineHeight + _size.margin * 2; if (_thumbnails) { for (int x = g.min.x; x < g.max.x && thumbnailWidth > 0; x += thumbnailWidth) { - const dtk::Box2I g2(x, y, thumbnailWidth, _size.thumbnailHeight); - if (dtk::intersects(g2, drawRect)) + const feather_tk::Box2I g2(x, y, thumbnailWidth, _size.thumbnailHeight); + if (feather_tk::intersects(g2, drawRect)) { const OTIO_NS::RationalTime t = posToTime(x); - std::shared_ptr image; + std::shared_ptr image; if (_thumbnailCache->get(getThumbnailCacheKey(nullptr, t, _size.thumbnailHeight), image)) { if (image) { event.render->drawImage( image, - dtk::Box2I(x, y, image->getWidth(), image->getHeight())); + feather_tk::Box2I(x, y, image->getWidth(), image->getHeight())); } } else @@ -237,8 +237,8 @@ namespace toucan while (i != _thumbnailRequests.end()) { const int x = timeToPos(i->time); - const dtk::Box2I g2(x, y, thumbnailWidth, _size.thumbnailHeight); - if (!dtk::intersects(g2, drawRect)) + const feather_tk::Box2I g2(x, y, thumbnailWidth, _size.thumbnailHeight); + if (!feather_tk::intersects(g2, drawRect)) { cancel.push_back(i->id); i = _thumbnailRequests.erase(i); @@ -251,26 +251,26 @@ namespace toucan _thumbnailGenerator->cancelThumbnails(cancel); } - void TimelineItem::drawOverlayEvent(const dtk::Box2I& drawRect, const dtk::DrawEvent& event) + void TimelineItem::drawOverlayEvent(const feather_tk::Box2I& drawRect, const feather_tk::DrawEvent& event) { IItem::drawOverlayEvent(drawRect, event); - const dtk::Box2I& g = getGeometry(); + const feather_tk::Box2I& g = getGeometry(); - const dtk::Box2I g2( + const feather_tk::Box2I g2( g.min.x, g.min.y + _size.scrollPos.y, g.w(), _size.fontMetrics.lineHeight + _size.margin * 2); - event.render->drawRect(g2, event.style->getColorRole(dtk::ColorRole::Base)); + event.render->drawRect(g2, event.style->getColorRole(feather_tk::ColorRole::Base)); if (_inOutRange != _timeRange) { const int x0 = timeToPos(_inOutRange.start_time()); const int x1 = timeToPos(_inOutRange.end_time_exclusive()); - dtk::Color4F color = event.style->getColorRole(dtk::ColorRole::Yellow); + feather_tk::Color4F color = event.style->getColorRole(feather_tk::ColorRole::Yellow); color.a = .5F; event.render->drawRect( - dtk::Box2I( + feather_tk::Box2I( x0, g.min.y + _size.scrollPos.y, x1 - x0, @@ -283,12 +283,12 @@ namespace toucan int pos = timeToPos(_currentTime); event.render->drawRect( - dtk::Box2I(pos, g.min.y + _size.scrollPos.y, _size.border * 2, g.h()), - event.style->getColorRole(dtk::ColorRole::Red)); + feather_tk::Box2I(pos, g.min.y + _size.scrollPos.y, _size.border * 2, g.h()), + event.style->getColorRole(feather_tk::ColorRole::Red)); std::string s = toString(_currentTime, _timeUnits); - dtk::Size2I size = event.fontSystem->getSize(s, _size.fontInfo); - dtk::Box2I g3( + feather_tk::Size2I size = event.fontSystem->getSize(s, _size.fontInfo); + feather_tk::Box2I g3( pos + _size.border * 2 + _size.margin, g.min.y + _size.scrollPos.y + _size.margin, size.w, @@ -302,10 +302,10 @@ namespace toucan event.fontSystem->getGlyphs(s, _size.fontInfo), _size.fontMetrics, g3.min, - event.style->getColorRole(dtk::ColorRole::Text)); + event.style->getColorRole(feather_tk::ColorRole::Text)); } - void TimelineItem::mouseMoveEvent(dtk::MouseMoveEvent& event) + void TimelineItem::mouseMoveEvent(feather_tk::MouseMoveEvent& event) { IItem::mouseMoveEvent(event); if (MouseMode::CurrentTime == _mouse.mode) @@ -319,13 +319,13 @@ namespace toucan } } - void TimelineItem::mousePressEvent(dtk::MouseClickEvent& event) + void TimelineItem::mousePressEvent(feather_tk::MouseClickEvent& event) { IItem::mousePressEvent(event); if (0 == event.button && (0 == event.modifiers || - static_cast(dtk::KeyModifier::Shift) == event.modifiers || - static_cast(dtk::commandKeyModifier) == event.modifiers)) + static_cast(feather_tk::KeyModifier::Shift) == event.modifiers || + static_cast(feather_tk::commandKeyModifier) == event.modifiers)) { std::shared_ptr selection; _select(shared_from_this(), event.pos, selection); @@ -342,12 +342,12 @@ namespace toucan _mouse.mode = MouseMode::Select; auto selectionPrev = _selectionModel->getSelection(); std::vector selectionNew; - if (static_cast(dtk::KeyModifier::Shift) == event.modifiers) + if (static_cast(feather_tk::KeyModifier::Shift) == event.modifiers) { selectionNew = selectionPrev; selectionNew.insert(selectionNew.end(), item); } - else if (static_cast(dtk::commandKeyModifier) == event.modifiers) + else if (static_cast(feather_tk::commandKeyModifier) == event.modifiers) { selectionNew = selectionPrev; auto i = std::find(selectionNew.begin(), selectionNew.end(), item); @@ -377,7 +377,7 @@ namespace toucan } } - void TimelineItem::mouseReleaseEvent(dtk::MouseClickEvent& event) + void TimelineItem::mouseReleaseEvent(feather_tk::MouseClickEvent& event) { IItem::mouseReleaseEvent(event); if (_mouse.mode != MouseMode::None) @@ -393,16 +393,16 @@ namespace toucan _setDrawUpdate(); } - dtk::Size2I TimelineItem::_getLabelMaxSize( - const std::shared_ptr& fontSystem) const + feather_tk::Size2I TimelineItem::_getLabelMaxSize( + const std::shared_ptr& fontSystem) const { const std::string labelMax = toString(_timeRange.end_time_inclusive(), _timeUnits); - const dtk::Size2I labelMaxSize = fontSystem->getSize(labelMax, _size.fontInfo); + const feather_tk::Size2I labelMaxSize = fontSystem->getSize(labelMax, _size.fontInfo); return labelMaxSize; } void TimelineItem::_getTimeTicks( - const std::shared_ptr& fontSystem, + const std::shared_ptr& fontSystem, double& seconds, int& tick) { @@ -411,7 +411,7 @@ namespace toucan const int secondsTick = 1.0 / duration * w; const int minutesTick = 60.0 / duration * w; const int hoursTick = 3600.0 / duration * w; - const dtk::Size2I labelMaxSize = _getLabelMaxSize(fontSystem); + const feather_tk::Size2I labelMaxSize = _getLabelMaxSize(fontSystem); const int distanceMin = _size.border + _size.margin + labelMaxSize.w; seconds = 0.0; tick = 0; @@ -433,18 +433,18 @@ namespace toucan } void TimelineItem::_drawTimeTicks( - const dtk::Box2I& drawRect, - const dtk::DrawEvent& event) + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent& event) { if (_timeRange != OTIO_NS::TimeRange()) { - const dtk::Box2I& g = getGeometry(); + const feather_tk::Box2I& g = getGeometry(); const int w = getSizeHint().w; const float duration = _timeRange.duration().rescaled_to(1.0).value(); const int frameTick = 1.0 / _timeRange.duration().value() * w; if (duration > 0.0 && frameTick >= _size.handle) { - dtk::TriMesh2F mesh; + feather_tk::TriMesh2F mesh; size_t i = 1; const OTIO_NS::RationalTime t0 = posToTime(g.min.x) - _timeRange.start_time(); const OTIO_NS::RationalTime t1 = posToTime(g.max.x) - _timeRange.start_time(); @@ -453,7 +453,7 @@ namespace toucan const double x1 = static_cast(t1.rescaled_to(1.0).value() / inc) * inc; for (double t = x0; t <= x1; t += inc) { - const dtk::Box2I box( + const feather_tk::Box2I box( g.min.x + t / duration * w, _size.scrollPos.y + @@ -463,10 +463,10 @@ namespace toucan _size.margin * 2); if (intersects(box, drawRect)) { - mesh.v.push_back(dtk::V2F(box.min.x, box.min.y)); - mesh.v.push_back(dtk::V2F(box.max.x + 1, box.min.y)); - mesh.v.push_back(dtk::V2F(box.max.x + 1, box.max.y + 1)); - mesh.v.push_back(dtk::V2F(box.min.x, box.max.y + 1)); + mesh.v.push_back(feather_tk::V2F(box.min.x, box.min.y)); + mesh.v.push_back(feather_tk::V2F(box.max.x + 1, box.min.y)); + mesh.v.push_back(feather_tk::V2F(box.max.x + 1, box.max.y + 1)); + mesh.v.push_back(feather_tk::V2F(box.min.x, box.max.y + 1)); mesh.triangles.push_back({ i + 0, i + 1, i + 2 }); mesh.triangles.push_back({ i + 2, i + 3, i + 0 }); i += 4; @@ -476,7 +476,7 @@ namespace toucan { event.render->drawMesh( mesh, - event.style->getColorRole(dtk::ColorRole::Button)); + event.style->getColorRole(feather_tk::ColorRole::Button)); } } @@ -485,7 +485,7 @@ namespace toucan _getTimeTicks(event.fontSystem, seconds, tick); if (duration > 0.0 && seconds > 0.0 && tick > 0) { - dtk::TriMesh2F mesh; + feather_tk::TriMesh2F mesh; size_t i = 1; const OTIO_NS::RationalTime t0 = posToTime(g.min.x) - _timeRange.start_time(); const OTIO_NS::RationalTime t1 = posToTime(g.max.x) - _timeRange.start_time(); @@ -494,7 +494,7 @@ namespace toucan const double x1 = static_cast(t1.rescaled_to(1.0).value() / inc) * inc; for (double t = x0; t <= x1; t += inc) { - const dtk::Box2I box( + const feather_tk::Box2I box( g.min.x + t / duration * w, _size.scrollPos.y + @@ -504,10 +504,10 @@ namespace toucan _size.margin * 2); if (intersects(box, drawRect)) { - mesh.v.push_back(dtk::V2F(box.min.x, box.min.y)); - mesh.v.push_back(dtk::V2F(box.max.x + 1, box.min.y)); - mesh.v.push_back(dtk::V2F(box.max.x + 1, box.max.y + 1)); - mesh.v.push_back(dtk::V2F(box.min.x, box.max.y + 1)); + mesh.v.push_back(feather_tk::V2F(box.min.x, box.min.y)); + mesh.v.push_back(feather_tk::V2F(box.max.x + 1, box.min.y)); + mesh.v.push_back(feather_tk::V2F(box.max.x + 1, box.max.y + 1)); + mesh.v.push_back(feather_tk::V2F(box.min.x, box.max.y + 1)); mesh.triangles.push_back({ i + 0, i + 1, i + 2 }); mesh.triangles.push_back({ i + 2, i + 3, i + 0 }); i += 4; @@ -517,19 +517,19 @@ namespace toucan { event.render->drawMesh( mesh, - event.style->getColorRole(dtk::ColorRole::Button)); + event.style->getColorRole(feather_tk::ColorRole::Button)); } } } } void TimelineItem::_drawTimeLabels( - const dtk::Box2I& drawRect, - const dtk::DrawEvent& event) + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent& event) { if (_timeRange != OTIO_NS::TimeRange()) { - const dtk::Box2I& g = getGeometry(); + const feather_tk::Box2I& g = getGeometry(); const int w = getSizeHint().w; const float duration = _timeRange.duration().rescaled_to(1.0).value(); double seconds = 0; @@ -537,7 +537,7 @@ namespace toucan _getTimeTicks(event.fontSystem, seconds, tick); if (seconds > 0.0 && tick > 0) { - const dtk::Size2I labelMaxSize = _getLabelMaxSize(event.fontSystem); + const feather_tk::Size2I labelMaxSize = _getLabelMaxSize(event.fontSystem); const OTIO_NS::RationalTime t0 = posToTime(g.min.x) - _timeRange.start_time(); const OTIO_NS::RationalTime t1 = posToTime(g.max.x) - _timeRange.start_time(); const double inc = seconds; @@ -547,7 +547,7 @@ namespace toucan { const OTIO_NS::RationalTime time = _timeRange.start_time() + OTIO_NS::RationalTime(t, 1.0).rescaled_to(_timeRange.duration().rate()); - const dtk::Box2I box( + const feather_tk::Box2I box( g.min.x + t / duration * w + _size.border + @@ -564,7 +564,7 @@ namespace toucan event.fontSystem->getGlyphs(label, _size.fontInfo), _size.fontMetrics, box.min, - event.style->getColorRole(dtk::ColorRole::TextDisabled)); + event.style->getColorRole(feather_tk::ColorRole::TextDisabled)); } } } @@ -572,20 +572,20 @@ namespace toucan } void TimelineItem::_select( - const std::shared_ptr& widget, - const dtk::V2I& pos, + const std::shared_ptr& widget, + const feather_tk::V2I& pos, std::shared_ptr& out) { if (auto iitem = std::dynamic_pointer_cast(widget)) { - if (dtk::contains(iitem->getSelectionRect(), pos)) + if (feather_tk::contains(iitem->getSelectionRect(), pos)) { out = iitem; } } for (const auto& child : widget->getChildren()) { - if (dtk::contains(child->getGeometry(), pos)) + if (feather_tk::contains(child->getGeometry(), pos)) { _select(child, pos, out); } @@ -593,7 +593,7 @@ namespace toucan } void TimelineItem::_select( - const std::shared_ptr& widget, + const std::shared_ptr& widget, const std::vector& selection) { if (auto iitem = std::dynamic_pointer_cast(widget)) diff --git a/lib/toucanView/TimelineItem.h b/lib/toucanView/TimelineItem.h index 763d9fc..65f6bad 100644 --- a/lib/toucanView/TimelineItem.h +++ b/lib/toucanView/TimelineItem.h @@ -6,7 +6,7 @@ #include #include -#include +#include namespace toucan { @@ -17,7 +17,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const std::shared_ptr& parent); @@ -26,7 +26,7 @@ namespace toucan //! Create a new item. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const std::shared_ptr& parent = nullptr); @@ -42,41 +42,41 @@ namespace toucan //! Set the in/out range. void setInOutRange(const OTIO_NS::TimeRange&); - void setGeometry(const dtk::Box2I&) override; + void setGeometry(const feather_tk::Box2I&) override; void tickEvent( bool parentsVisible, bool parentsEnabled, - const dtk::TickEvent&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; - void drawOverlayEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; - void mouseMoveEvent(dtk::MouseMoveEvent&) override; - void mousePressEvent(dtk::MouseClickEvent&) override; - void mouseReleaseEvent(dtk::MouseClickEvent&) override; + const feather_tk::TickEvent&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; + void drawOverlayEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; + void mouseMoveEvent(feather_tk::MouseMoveEvent&) override; + void mousePressEvent(feather_tk::MouseClickEvent&) override; + void mouseReleaseEvent(feather_tk::MouseClickEvent&) override; protected: void _timeUnitsUpdate() override; private: - dtk::Size2I _getLabelMaxSize( - const std::shared_ptr&) const; + feather_tk::Size2I _getLabelMaxSize( + const std::shared_ptr&) const; void _getTimeTicks( - const std::shared_ptr&, + const std::shared_ptr&, double& seconds, int& tick); void _drawTimeTicks( - const dtk::Box2I&, - const dtk::DrawEvent&); + const feather_tk::Box2I&, + const feather_tk::DrawEvent&); void _drawTimeLabels( - const dtk::Box2I&, - const dtk::DrawEvent&); + const feather_tk::Box2I&, + const feather_tk::DrawEvent&); void _select( - const std::shared_ptr&, - const dtk::V2I&, + const std::shared_ptr&, + const feather_tk::V2I&, std::shared_ptr&); void _select( - const std::shared_ptr&, + const std::shared_ptr&, const std::vector&); OTIO_NS::SerializableObject::Retainer _timeline; @@ -88,7 +88,7 @@ namespace toucan bool _thumbnails = true; std::shared_ptr _thumbnailGenerator; std::list _thumbnailRequests; - std::shared_ptr > > _thumbnailCache; + std::shared_ptr > > _thumbnailCache; struct SizeData { @@ -98,9 +98,9 @@ namespace toucan int border = 0; int handle = 0; int thumbnailHeight = 0; - dtk::FontInfo fontInfo; - dtk::FontMetrics fontMetrics; - dtk::V2I scrollPos; + feather_tk::FontInfo fontInfo; + feather_tk::FontMetrics fontMetrics; + feather_tk::V2I scrollPos; }; SizeData _size; @@ -116,7 +116,7 @@ namespace toucan }; MouseData _mouse; - std::shared_ptr > _selectionObserver; - std::shared_ptr > _thumbnailsObserver; + std::shared_ptr > _selectionObserver; + std::shared_ptr > _thumbnailsObserver; }; } diff --git a/lib/toucanView/TimelineWidget.cpp b/lib/toucanView/TimelineWidget.cpp index e9c805c..b2cee89 100644 --- a/lib/toucanView/TimelineWidget.cpp +++ b/lib/toucanView/TimelineWidget.cpp @@ -16,7 +16,7 @@ namespace toucan } void TimelineWidget::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& parent) { @@ -26,16 +26,16 @@ namespace toucan _setMousePressEnabled( true, 0, - static_cast(dtk::KeyModifier::Alt)); + static_cast(feather_tk::KeyModifier::Alt)); - _frameView = dtk::ObservableValue::create(true); + _frameView = feather_tk::ObservableValue::create(true); - _scrollWidget = dtk::ScrollWidget::create(context, dtk::ScrollType::Both, shared_from_this()); + _scrollWidget = feather_tk::ScrollWidget::create(context, feather_tk::ScrollType::Both, shared_from_this()); _scrollWidget->setScrollEventsEnabled(false); _scrollWidget->setBorder(false); auto appWeak = std::weak_ptr(app); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this, appWeak](const std::shared_ptr& file) { @@ -65,7 +65,7 @@ namespace toucan data.app = appWeak.lock(); data.file = file; data.thumbnailGenerator = file->getThumbnailGenerator(); - data.thumbnailCache = std::make_shared > >(); + data.thumbnailCache = std::make_shared > >(); data.thumbnailCache->setMax(1000); _timelineItem = TimelineItem::create(getContext(), data); _timelineItem->setScale(_scale); @@ -79,7 +79,7 @@ namespace toucan }); _scrollWidget->setWidget(_timelineItem); - _currentTimeObserver = dtk::ValueObserver::create( + _currentTimeObserver = feather_tk::ValueObserver::create( file->getPlaybackModel()->observeCurrentTime(), [this](const OTIO_NS::RationalTime& value) { @@ -91,7 +91,7 @@ namespace toucan _scrollUpdate(); }); - _inOutRangeObserver = dtk::ValueObserver::create( + _inOutRangeObserver = feather_tk::ValueObserver::create( file->getPlaybackModel()->observeInOutRange(), [this](const OTIO_NS::TimeRange& value) { @@ -119,7 +119,7 @@ namespace toucan {} std::shared_ptr TimelineWidget::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& parent) { @@ -130,11 +130,11 @@ namespace toucan void TimelineWidget::setViewZoom(double value) { - const dtk::Box2I& g = getGeometry(); - setViewZoom(value, dtk::V2I(g.w() / 2, g.h() / 2)); + const feather_tk::Box2I& g = getGeometry(); + setViewZoom(value, feather_tk::V2I(g.w() / 2, g.h() / 2)); } - void TimelineWidget::setViewZoom(double zoom, const dtk::V2I& focus) + void TimelineWidget::setViewZoom(double zoom, const feather_tk::V2I& focus) { _setViewZoom( zoom, @@ -148,7 +148,7 @@ namespace toucan return _frameView->get(); } - std::shared_ptr > TimelineWidget::observeFrameView() const + std::shared_ptr > TimelineWidget::observeFrameView() const { return _frameView; } @@ -166,7 +166,7 @@ namespace toucan void TimelineWidget::frameView() { - dtk::V2I pos = _scrollWidget->getScrollPos(); + feather_tk::V2I pos = _scrollWidget->getScrollPos(); pos.x = 0; _scrollWidget->setScrollPos(pos); _scale = _getTimelineScale(); @@ -178,9 +178,9 @@ namespace toucan _setDrawUpdate(); } - void TimelineWidget::setGeometry(const dtk::Box2I& value) + void TimelineWidget::setGeometry(const feather_tk::Box2I& value) { - const dtk::Box2I viewportPrev = _scrollWidget->getViewport(); + const feather_tk::Box2I viewportPrev = _scrollWidget->getViewport(); IWidget::setGeometry(value); _scrollWidget->setGeometry(value); const bool changed = _scrollWidget->getViewport() != viewportPrev; @@ -208,20 +208,20 @@ namespace toucan } } - void TimelineWidget::sizeHintEvent(const dtk::SizeHintEvent& event) + void TimelineWidget::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); _setSizeHint(_scrollWidget->getSizeHint()); } - void TimelineWidget::mouseMoveEvent(dtk::MouseMoveEvent& event) + void TimelineWidget::mouseMoveEvent(feather_tk::MouseMoveEvent& event) { IWidget::mouseMoveEvent(event); switch (_mouse.mode) { case MouseMode::Scroll: { - const dtk::V2I d = event.pos - _getMousePressPos(); + const feather_tk::V2I d = event.pos - _getMousePressPos(); _scrollWidget->setScrollPos(_mouse.scrollPos - d); setFrameView(false); break; @@ -230,11 +230,11 @@ namespace toucan } } - void TimelineWidget::mousePressEvent(dtk::MouseClickEvent& event) + void TimelineWidget::mousePressEvent(feather_tk::MouseClickEvent& event) { IWidget::mousePressEvent(event); if (0 == event.button && - static_cast(dtk::KeyModifier::Alt) == event.modifiers) + static_cast(feather_tk::KeyModifier::Alt) == event.modifiers) { event.accept = true; takeKeyFocus(); @@ -247,12 +247,12 @@ namespace toucan } } - void TimelineWidget::mouseReleaseEvent(dtk::MouseClickEvent& event) + void TimelineWidget::mouseReleaseEvent(feather_tk::MouseClickEvent& event) { IWidget::mouseReleaseEvent(event); } - void TimelineWidget::scrollEvent(dtk::ScrollEvent& event) + void TimelineWidget::scrollEvent(feather_tk::ScrollEvent& event) { IWidget::scrollEvent(event); event.accept = true; @@ -268,21 +268,21 @@ namespace toucan } } - void TimelineWidget::keyPressEvent(dtk::KeyEvent& event) + void TimelineWidget::keyPressEvent(feather_tk::KeyEvent& event) { if (0 == event.modifiers) { switch (event.key) { - case dtk::Key::Equal: + case feather_tk::Key::Equal: event.accept = true; setViewZoom(_scale * 2.0, event.pos); break; - case dtk::Key::Minus: + case feather_tk::Key::Minus: event.accept = true; setViewZoom(_scale / 2.0, event.pos); break; - case dtk::Key::Backspace: + case feather_tk::Key::Backspace: event.accept = true; setFrameView(true); break; @@ -291,7 +291,7 @@ namespace toucan } } - void TimelineWidget::keyReleaseEvent(dtk::KeyEvent& event) + void TimelineWidget::keyReleaseEvent(feather_tk::KeyEvent& event) { event.accept = true; } @@ -299,13 +299,13 @@ namespace toucan void TimelineWidget::_setViewZoom( double zoomNew, double zoomPrev, - const dtk::V2I& focus, - const dtk::V2I& scrollPos) + const feather_tk::V2I& focus, + const feather_tk::V2I& scrollPos) { const int w = getGeometry().w(); const double zoomMin = _getTimelineScale(); const double zoomMax = _getTimelineScaleMax(); - const double zoomClamped = dtk::clamp(zoomNew, zoomMin, zoomMax); + const double zoomClamped = feather_tk::clamp(zoomNew, zoomMin, zoomMax); if (zoomClamped != _scale) { _scale = zoomClamped; @@ -314,7 +314,7 @@ namespace toucan _timelineItem->setScale(_scale); } const double s = zoomClamped / zoomPrev; - const dtk::V2I scrollPosNew( + const feather_tk::V2I scrollPosNew( (scrollPos.x + focus.x) * s - focus.x, scrollPos.y); _scrollWidget->setScrollPos(scrollPosNew, false); @@ -329,7 +329,7 @@ namespace toucan const double duration = _timeRange.duration().rescaled_to(1.0).value(); if (duration > 0.0) { - const dtk::Box2I scrollViewport = _scrollWidget->getViewport(); + const feather_tk::Box2I scrollViewport = _scrollWidget->getViewport(); out = scrollViewport.w() / duration; } return out; @@ -338,7 +338,7 @@ namespace toucan double TimelineWidget::_getTimelineScaleMax() const { double out = 1.0; - const dtk::Box2I scrollViewport = _scrollWidget->getViewport(); + const feather_tk::Box2I scrollViewport = _scrollWidget->getViewport(); const double duration = _timeRange.duration().rescaled_to(1.0).value(); if (duration < 1.0) { @@ -360,14 +360,14 @@ namespace toucan MouseMode::None == _mouse.mode) { const int pos = _timelineItem->timeToPos(_currentTime); - const dtk::Box2I vp = _scrollWidget->getViewport(); + const feather_tk::Box2I vp = _scrollWidget->getViewport(); const int margin = vp.w() * marginPercentage; if (pos < (vp.min.x + margin) || pos >(vp.max.x - margin)) { const int offset = pos < (vp.min.x + margin) ? (vp.min.x + margin) : (vp.max.x - margin); const OTIO_NS::RationalTime t = _currentTime - _timeRange.start_time(); - dtk::V2I scrollPos = _scrollWidget->getScrollPos(); - const dtk::Box2I& g = getGeometry(); + feather_tk::V2I scrollPos = _scrollWidget->getScrollPos(); + const feather_tk::Box2I& g = getGeometry(); scrollPos.x = g.min.x - offset + t.rescaled_to(1.0).value() * _scale; _scrollWidget->setScrollPos(scrollPos); } diff --git a/lib/toucanView/TimelineWidget.h b/lib/toucanView/TimelineWidget.h index a13acd1..fbbfdc3 100644 --- a/lib/toucanView/TimelineWidget.h +++ b/lib/toucanView/TimelineWidget.h @@ -6,8 +6,8 @@ #include #include -#include -#include +#include +#include #include @@ -18,11 +18,11 @@ namespace toucan class TimelineItem; //! Timeline widget. - class TimelineWidget : public dtk::IWidget + class TimelineWidget : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -31,7 +31,7 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); @@ -39,13 +39,13 @@ namespace toucan void setViewZoom(double); //! Set the view zoom with focus. - void setViewZoom(double, const dtk::V2I& focus); + void setViewZoom(double, const feather_tk::V2I& focus); //! Get whether frame view is enabled. bool hasFrameView() const; //! Observe whether frame view is enabled. - std::shared_ptr > observeFrameView() const; + std::shared_ptr > observeFrameView() const; //! Set whether frame view is enabled. void setFrameView(bool); @@ -53,21 +53,21 @@ namespace toucan //! Frame the view. void frameView(); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void mouseMoveEvent(dtk::MouseMoveEvent&) override; - void mousePressEvent(dtk::MouseClickEvent&) override; - void mouseReleaseEvent(dtk::MouseClickEvent&) override; - void scrollEvent(dtk::ScrollEvent&) override; - void keyPressEvent(dtk::KeyEvent&) override; - void keyReleaseEvent(dtk::KeyEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void mouseMoveEvent(feather_tk::MouseMoveEvent&) override; + void mousePressEvent(feather_tk::MouseClickEvent&) override; + void mouseReleaseEvent(feather_tk::MouseClickEvent&) override; + void scrollEvent(feather_tk::ScrollEvent&) override; + void keyPressEvent(feather_tk::KeyEvent&) override; + void keyReleaseEvent(feather_tk::KeyEvent&) override; private: void _setViewZoom( double zoomNew, double zoomPrev, - const dtk::V2I& focus, - const dtk::V2I& scrollPos); + const feather_tk::V2I& focus, + const feather_tk::V2I& scrollPos); double _getTimelineScale() const; double _getTimelineScaleMax() const; @@ -79,11 +79,11 @@ namespace toucan OTIO_NS::RationalTime _currentTime; OTIO_NS::TimeRange _inOutRange; double _scale = 100.0; - std::shared_ptr > _frameView; + std::shared_ptr > _frameView; bool _sizeInit = true; std::optional _viewState; - std::shared_ptr _scrollWidget; + std::shared_ptr _scrollWidget; std::shared_ptr _timelineItem; enum class MouseMode @@ -94,13 +94,13 @@ namespace toucan struct MouseData { MouseMode mode = MouseMode::None; - dtk::V2I scrollPos; + feather_tk::V2I scrollPos; std::chrono::steady_clock::time_point wheelTimer; }; MouseData _mouse; - std::shared_ptr > > _fileObserver; - std::shared_ptr > _currentTimeObserver; - std::shared_ptr > _inOutRangeObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > _currentTimeObserver; + std::shared_ptr > _inOutRangeObserver; }; } diff --git a/lib/toucanView/ToolBar.cpp b/lib/toucanView/ToolBar.cpp index cc65fd6..e014c7b 100644 --- a/lib/toucanView/ToolBar.cpp +++ b/lib/toucanView/ToolBar.cpp @@ -7,29 +7,29 @@ #include "ViewToolBar.h" #include "WindowToolBar.h" -#include +#include namespace toucan { void ToolBar::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& window, - const std::map >& actions, - const std::shared_ptr& parent) + const std::map >& actions, + const std::shared_ptr& parent) { - dtk::IWidget::_init(context, "toucan::ToolBar", parent); + feather_tk::IWidget::_init(context, "toucan::ToolBar", parent); - _layout = dtk::HorizontalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingSmall); + _layout = feather_tk::HorizontalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); _toolBars["File"] = FileToolBar::create(context, app, actions, _layout); - dtk::Divider::create(context, dtk::Orientation::Horizontal, _layout); + feather_tk::Divider::create(context, feather_tk::Orientation::Horizontal, _layout); _toolBars["View"] = ViewToolBar::create(context, app, actions, _layout); - dtk::Divider::create(context, dtk::Orientation::Horizontal, _layout); + feather_tk::Divider::create(context, feather_tk::Orientation::Horizontal, _layout); _toolBars["Window"] = WindowToolBar::create(context, app, window, actions, _layout); } @@ -38,24 +38,24 @@ namespace toucan {} std::shared_ptr ToolBar::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& window, - const std::map >& actions, - const std::shared_ptr& parent) + const std::map >& actions, + const std::shared_ptr& parent) { auto out = std::shared_ptr(new ToolBar); out->_init(context, app, window, actions, parent); return out; } - void ToolBar::setGeometry(const dtk::Box2I& value) + void ToolBar::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void ToolBar::sizeHintEvent(const dtk::SizeHintEvent& event) + void ToolBar::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); diff --git a/lib/toucanView/ToolBar.h b/lib/toucanView/ToolBar.h index b19eeff..7b62dfb 100644 --- a/lib/toucanView/ToolBar.h +++ b/lib/toucanView/ToolBar.h @@ -3,8 +3,8 @@ #pragma once -#include -#include +#include +#include namespace toucan { @@ -12,14 +12,14 @@ namespace toucan class MainWindow; //! Tool bar. - class ToolBar : public dtk::IWidget + class ToolBar : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, - const std::map >&, + const std::map >&, const std::shared_ptr& parent); public: @@ -27,18 +27,18 @@ namespace toucan //! Create a new tool bar. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, - const std::map >&, + const std::map >&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: - std::shared_ptr _layout; - std::map > _toolBars; + std::shared_ptr _layout; + std::map > _toolBars; }; } diff --git a/lib/toucanView/TrackItem.cpp b/lib/toucanView/TrackItem.cpp index 5e43842..ed51dda 100644 --- a/lib/toucanView/TrackItem.cpp +++ b/lib/toucanView/TrackItem.cpp @@ -7,13 +7,13 @@ #include "GapItem.h" #include "VideoClipItem.h" -#include -#include +#include +#include namespace toucan { void TrackItem::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& track, const OTIO_NS::SerializableObject::Retainer& timeline, @@ -42,13 +42,13 @@ namespace toucan _track = track; _text = !track->name().empty() ? track->name() : (track->kind() + " Track"); _color = OTIO_NS::Track::Kind::video == track->kind() ? - dtk::Color4F(.2F, .2F, .3F) : - dtk::Color4F(.2F, .3F, .2F); + feather_tk::Color4F(.2F, .2F, .3F) : + feather_tk::Color4F(.2F, .3F, .2F); setTooltip(track->schema_name() + ": " + _text); - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingTool); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingTool); _label = ItemLabel::create(context, _layout); _label->setName(_text); @@ -90,7 +90,7 @@ namespace toucan data, clip, timeline, - dtk::Color4F(.4F, .4F, .6F), + feather_tk::Color4F(.4F, .4F, .6F), _timeLayout); } else if (OTIO_NS::Track::Kind::audio == track->kind()) @@ -100,7 +100,7 @@ namespace toucan data, clip, timeline, - dtk::Color4F(.4F, .6F, .4F), + feather_tk::Color4F(.4F, .6F, .4F), _timeLayout); } } @@ -122,7 +122,7 @@ namespace toucan {} std::shared_ptr TrackItem::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& track, const OTIO_NS::SerializableObject::Retainer& timeline, @@ -143,21 +143,21 @@ namespace toucan _timeLayout->setScale(value); } - void TrackItem::setGeometry(const dtk::Box2I& value) + void TrackItem::setGeometry(const feather_tk::Box2I& value) { IItem::setGeometry(value); _layout->setGeometry(value); - _geom.g2 = dtk::margin(value, -_size.border, 0, -_size.border, 0); - _geom.g3 = dtk::margin(_label->getGeometry(), -_size.border, 0, -_size.border, 0); + _geom.g2 = feather_tk::margin(value, -_size.border, 0, -_size.border, 0); + _geom.g3 = feather_tk::margin(_label->getGeometry(), -_size.border, 0, -_size.border, 0); _selectionRect = _geom.g3; } - dtk::Box2I TrackItem::getChildrenClipRect() const + feather_tk::Box2I TrackItem::getChildrenClipRect() const { return _geom.g2; } - void TrackItem::sizeHintEvent(const dtk::SizeHintEvent& event) + void TrackItem::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IItem::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -165,19 +165,19 @@ namespace toucan { _size.init = false; _size.displayScale = event.displayScale; - _size.border = event.style->getSizeRole(dtk::SizeRole::Border, event.displayScale); + _size.border = event.style->getSizeRole(feather_tk::SizeRole::Border, event.displayScale); } _setSizeHint(_layout->getSizeHint()); } void TrackItem::drawEvent( - const dtk::Box2I& drawRect, - const dtk::DrawEvent& event) + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent& event) { IItem::drawEvent(drawRect, event); event.render->drawRect( _geom.g3, - _selected ? event.style->getColorRole(dtk::ColorRole::Yellow) : _color); + _selected ? event.style->getColorRole(feather_tk::ColorRole::Yellow) : _color); } void TrackItem::_timeUnitsUpdate() diff --git a/lib/toucanView/TrackItem.h b/lib/toucanView/TrackItem.h index 504e8af..9ac29d1 100644 --- a/lib/toucanView/TrackItem.h +++ b/lib/toucanView/TrackItem.h @@ -5,7 +5,7 @@ #include -#include +#include #include @@ -16,7 +16,7 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::SerializableObject::Retainer&, @@ -27,7 +27,7 @@ namespace toucan //! Create a new item. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::SerializableObject::Retainer&, @@ -35,10 +35,10 @@ namespace toucan void setScale(double) override; - void setGeometry(const dtk::Box2I&) override; - dtk::Box2I getChildrenClipRect() const override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + feather_tk::Box2I getChildrenClipRect() const override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; protected: void _timeUnitsUpdate() override; @@ -48,9 +48,9 @@ namespace toucan OTIO_NS::SerializableObject::Retainer _track; std::string _text; - dtk::Color4F _color; + feather_tk::Color4F _color; - std::shared_ptr _layout; + std::shared_ptr _layout; std::shared_ptr _label; std::shared_ptr _markerLayout; std::vector > _markerItems; @@ -66,8 +66,8 @@ namespace toucan struct GeomData { - dtk::Box2I g2; - dtk::Box2I g3; + feather_tk::Box2I g2; + feather_tk::Box2I g3; }; GeomData _geom; }; diff --git a/lib/toucanView/VideoClipItem.cpp b/lib/toucanView/VideoClipItem.cpp index d2f6194..38d1e7d 100644 --- a/lib/toucanView/VideoClipItem.cpp +++ b/lib/toucanView/VideoClipItem.cpp @@ -9,7 +9,7 @@ #include -#include +#include #include #include @@ -17,11 +17,11 @@ namespace toucan { void VideoClipItem::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& clip, const OTIO_NS::SerializableObject::Retainer& timeline, - const dtk::Color4F& color, + const feather_tk::Color4F& color, const std::shared_ptr& parent) { OTIO_NS::TimeRange timeRange = clip->transformed_time_range( @@ -50,8 +50,8 @@ namespace toucan setTooltip(clip->schema_name() + ": " + _text); - _layout = dtk::VerticalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingTool); + _layout = feather_tk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingTool); _label = ItemLabel::create(context, _layout); _label->setName(_text); @@ -93,7 +93,7 @@ namespace toucan _textUpdate(); - _thumbnailsObserver = dtk::ValueObserver::create( + _thumbnailsObserver = feather_tk::ValueObserver::create( data.app->getWindowModel()->observeThumbnails(), [this](bool value) { @@ -105,11 +105,11 @@ namespace toucan {} std::shared_ptr VideoClipItem::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const ItemData& data, const OTIO_NS::SerializableObject::Retainer& clip, const OTIO_NS::SerializableObject::Retainer& timeline, - const dtk::Color4F& color, + const feather_tk::Color4F& color, const std::shared_ptr& parent) { auto out = std::make_shared(); @@ -126,18 +126,18 @@ namespace toucan } } - void VideoClipItem::setGeometry(const dtk::Box2I& value) + void VideoClipItem::setGeometry(const feather_tk::Box2I& value) { IItem::setGeometry(value); _layout->setGeometry(value); } - dtk::Box2I VideoClipItem::getChildrenClipRect() const + feather_tk::Box2I VideoClipItem::getChildrenClipRect() const { - return dtk::margin(getGeometry(), -_size.border, 0, -_size.border, 0); + return feather_tk::margin(getGeometry(), -_size.border, 0, -_size.border, 0); } - void VideoClipItem::sizeHintEvent(const dtk::SizeHintEvent& event) + void VideoClipItem::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IItem::sizeHintEvent(event); const bool displayScaleChanged = event.displayScale != _size.displayScale; @@ -145,26 +145,26 @@ namespace toucan { _size.init = false; _size.displayScale = event.displayScale; - _size.border = event.style->getSizeRole(dtk::SizeRole::Border, event.displayScale); + _size.border = event.style->getSizeRole(feather_tk::SizeRole::Border, event.displayScale); } - dtk::Size2I sizeHint = _layout->getSizeHint(); + feather_tk::Size2I sizeHint = _layout->getSizeHint(); _setSizeHint(sizeHint); } void VideoClipItem::drawEvent( - const dtk::Box2I& drawRect, - const dtk::DrawEvent& event) + const feather_tk::Box2I& drawRect, + const feather_tk::DrawEvent& event) { IItem::drawEvent(drawRect, event); - dtk::Box2I g = _label->getGeometry(); + feather_tk::Box2I g = _label->getGeometry(); if (_thumbnailsWidget->isVisible(true)) { - const dtk::Box2I& g2 = _thumbnailsWidget->getGeometry(); - g = dtk::Box2I(g.min, g2.max); + const feather_tk::Box2I& g2 = _thumbnailsWidget->getGeometry(); + g = feather_tk::Box2I(g.min, g2.max); } event.render->drawRect( - dtk::margin(g, -_size.border, 0, -_size.border, 0), - _selected ? event.style->getColorRole(dtk::ColorRole::Yellow) : _color); + feather_tk::margin(g, -_size.border, 0, -_size.border, 0), + _selected ? event.style->getColorRole(feather_tk::ColorRole::Yellow) : _color); } void VideoClipItem::_timeUnitsUpdate() @@ -172,11 +172,11 @@ namespace toucan _textUpdate(); } - void VideoClipItem::_buildMenu(const std::shared_ptr& menu) + void VideoClipItem::_buildMenu(const std::shared_ptr& menu) { if (auto externalReference = dynamic_cast(_clip->media_reference())) { - auto action = std::make_shared( + auto action = feather_tk::Action::create( "Open Media", [this, externalReference] { @@ -185,12 +185,12 @@ namespace toucan auto app = _app.lock(); app->open(path); }); - menu->addItem(action); + menu->addAction(action); menu->addDivider(); } else if (auto sequenceRef = dynamic_cast(_clip->media_reference())) { - auto action = std::make_shared( + auto action = feather_tk::Action::create( "Open Image Sequence", [this, sequenceRef] { @@ -204,7 +204,7 @@ namespace toucan auto app = _app.lock(); app->open(path); }); - menu->addItem(action); + menu->addAction(action); menu->addDivider(); } IItem::_buildMenu(menu); diff --git a/lib/toucanView/VideoClipItem.h b/lib/toucanView/VideoClipItem.h index 4e7ce3c..8511dcb 100644 --- a/lib/toucanView/VideoClipItem.h +++ b/lib/toucanView/VideoClipItem.h @@ -8,7 +8,7 @@ #include #include -#include +#include #include @@ -19,11 +19,11 @@ namespace toucan { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::SerializableObject::Retainer&, - const dtk::Color4F&, + const feather_tk::Color4F&, const std::shared_ptr& parent); public: @@ -31,39 +31,39 @@ namespace toucan //! Create a new item. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const ItemData&, const OTIO_NS::SerializableObject::Retainer&, const OTIO_NS::SerializableObject::Retainer&, - const dtk::Color4F&, + const feather_tk::Color4F&, const std::shared_ptr& parent = nullptr); void setScale(double) override; - void setGeometry(const dtk::Box2I&) override; - dtk::Box2I getChildrenClipRect() const override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + feather_tk::Box2I getChildrenClipRect() const override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; protected: void _timeUnitsUpdate() override; - void _buildMenu(const std::shared_ptr&) override; + void _buildMenu(const std::shared_ptr&) override; private: void _textUpdate(); OTIO_NS::SerializableObject::Retainer _clip; std::string _text; - dtk::Color4F _color; + feather_tk::Color4F _color; std::string _url; - std::shared_ptr _layout; + std::shared_ptr _layout; std::shared_ptr _label; std::shared_ptr _thumbnailsWidget; std::shared_ptr _markerLayout; std::vector > _markerItems; - std::shared_ptr > _thumbnailsObserver; + std::shared_ptr > _thumbnailsObserver; struct SizeData { @@ -75,8 +75,8 @@ namespace toucan struct GeomData { - dtk::Box2I g2; - dtk::Box2I g3; + feather_tk::Box2I g2; + feather_tk::Box2I g3; }; GeomData _geom; }; diff --git a/lib/toucanView/ViewMenu.cpp b/lib/toucanView/ViewMenu.cpp index d2738c1..04401d5 100644 --- a/lib/toucanView/ViewMenu.cpp +++ b/lib/toucanView/ViewMenu.cpp @@ -9,16 +9,16 @@ namespace toucan { void ViewMenu::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::Menu::_init(context, parent); + feather_tk::Menu::_init(context, parent); - _actions["View/ZoomIn"] = std::make_shared( + _actions["View/ZoomIn"] = feather_tk::Action::create( "Zoom In", "ViewZoomIn", - dtk::Key::Equal, + feather_tk::Key::Equal, 0, [this] { @@ -27,13 +27,13 @@ namespace toucan _file->getViewModel()->zoomIn(); } }); - _actions["View/ZoomIn"]->toolTip = "View zoom in"; - addItem(_actions["View/ZoomIn"]); + _actions["View/ZoomIn"]->setTooltip("View zoom in"); + addAction(_actions["View/ZoomIn"]); - _actions["View/ZoomOut"] = std::make_shared( + _actions["View/ZoomOut"] = feather_tk::Action::create( "Zoom Out", "ViewZoomOut", - dtk::Key::Minus, + feather_tk::Key::Minus, 0, [this] { @@ -42,13 +42,13 @@ namespace toucan _file->getViewModel()->zoomOut(); } }); - _actions["View/ZoomOut"]->toolTip = "View zoom out"; - addItem(_actions["View/ZoomOut"]); + _actions["View/ZoomOut"]->setTooltip("View zoom out"); + addAction(_actions["View/ZoomOut"]); - _actions["View/ZoomReset"] = std::make_shared( + _actions["View/ZoomReset"] = feather_tk::Action::create( "Zoom Reset", "ViewZoomReset", - dtk::Key::_0, + feather_tk::Key::_0, 0, [this] { @@ -57,15 +57,15 @@ namespace toucan _file->getViewModel()->zoomReset(); } }); - _actions["View/ZoomReset"]->toolTip = "Reset the view zoom"; - addItem(_actions["View/ZoomReset"]); + _actions["View/ZoomReset"]->setTooltip("Reset the view zoom"); + addAction(_actions["View/ZoomReset"]); addDivider(); - _actions["View/Frame"] = std::make_shared( + _actions["View/Frame"] = feather_tk::Action::create( "Frame View", "ViewFrame", - dtk::Key::Backspace, + feather_tk::Key::Backspace, 0, [this](bool value) { @@ -74,14 +74,14 @@ namespace toucan _file->getViewModel()->setFrameView(value); } }); - _actions["View/Frame"]->toolTip = "Frame the view"; - addItem(_actions["View/Frame"]); + _actions["View/Frame"]->setTooltip("Frame the view"); + addAction(_actions["View/Frame"]); addDivider(); - _actions["View/Flip"] = std::make_shared( + _actions["View/Flip"] = feather_tk::Action::create( "Flip Vertical", - dtk::Key::V, + feather_tk::Key::V, 0, [this](bool value) { @@ -92,11 +92,11 @@ namespace toucan _file->getViewModel()->setOptions(options); } }); - addItem(_actions["View/Flip"]); + addAction(_actions["View/Flip"]); - _actions["View/Flop"] = std::make_shared( + _actions["View/Flop"] = feather_tk::Action::create( "Flop Horizontal", - dtk::Key::H, + feather_tk::Key::H, 0, [this](bool value) { @@ -107,77 +107,77 @@ namespace toucan _file->getViewModel()->setOptions(options); } }); - addItem(_actions["View/Flop"]); + addAction(_actions["View/Flop"]); addDivider(); - _actions["View/Red"] = std::make_shared( + _actions["View/Red"] = feather_tk::Action::create( "Red", - dtk::Key::R, + feather_tk::Key::R, 0, [this](bool value) { if (_file) { ViewOptions options = _file->getViewModel()->getOptions(); - options.channelDisplay = value ? dtk::ChannelDisplay::Red : dtk::ChannelDisplay::Color; + options.channelDisplay = value ? feather_tk::ChannelDisplay::Red : feather_tk::ChannelDisplay::Color; _file->getViewModel()->setOptions(options); } }); - addItem(_actions["View/Red"]); + addAction(_actions["View/Red"]); - _actions["View/Green"] = std::make_shared( + _actions["View/Green"] = feather_tk::Action::create( "Green", - dtk::Key::G, + feather_tk::Key::G, 0, [this](bool value) { if (_file) { ViewOptions options = _file->getViewModel()->getOptions(); - options.channelDisplay = value ? dtk::ChannelDisplay::Green : dtk::ChannelDisplay::Color; + options.channelDisplay = value ? feather_tk::ChannelDisplay::Green : feather_tk::ChannelDisplay::Color; _file->getViewModel()->setOptions(options); } }); - addItem(_actions["View/Green"]); + addAction(_actions["View/Green"]); - _actions["View/Blue"] = std::make_shared( + _actions["View/Blue"] = feather_tk::Action::create( "Blue", - dtk::Key::B, + feather_tk::Key::B, 0, [this](bool value) { if (_file) { ViewOptions options = _file->getViewModel()->getOptions(); - options.channelDisplay = value ? dtk::ChannelDisplay::Blue : dtk::ChannelDisplay::Color; + options.channelDisplay = value ? feather_tk::ChannelDisplay::Blue : feather_tk::ChannelDisplay::Color; _file->getViewModel()->setOptions(options); } }); - addItem(_actions["View/Blue"]); + addAction(_actions["View/Blue"]); - _actions["View/Alpha"] = std::make_shared( + _actions["View/Alpha"] = feather_tk::Action::create( "Alpha", - dtk::Key::A, + feather_tk::Key::A, 0, [this](bool value) { if (_file) { ViewOptions options = _file->getViewModel()->getOptions(); - options.channelDisplay = value ? dtk::ChannelDisplay::Alpha : dtk::ChannelDisplay::Color; + options.channelDisplay = value ? feather_tk::ChannelDisplay::Alpha : feather_tk::ChannelDisplay::Color; _file->getViewModel()->setOptions(options); } }); - addItem(_actions["View/Alpha"]); + addAction(_actions["View/Alpha"]); addDivider(); std::weak_ptr appWeak(app); - _actions["View/HUD"] = std::make_shared( + _actions["View/HUD"] = feather_tk::Action::create( "HUD", - dtk::Key::H, - static_cast(dtk::commandKeyModifier), + feather_tk::Key::H, + static_cast(feather_tk::commandKeyModifier), [appWeak](bool value) { if (auto app = appWeak.lock()) @@ -187,10 +187,10 @@ namespace toucan app->getGlobalViewModel()->setOptions(options); } }); - _actions["View/HUD"]->toolTip = "Toggle the HUD (Heads Up Display)"; - addItem(_actions["View/HUD"]); + _actions["View/HUD"]->setTooltip("Toggle the HUD (Heads Up Display)"); + addAction(_actions["View/HUD"]); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { @@ -198,11 +198,11 @@ namespace toucan _menuUpdate(); }); - _globalOptionsObserver = dtk::ValueObserver::create( + _globalOptionsObserver = feather_tk::ValueObserver::create( app->getGlobalViewModel()->observeOptions(), [this](const GlobalViewOptions& value) { - setItemChecked(_actions["View/HUD"], value.hud); + setChecked(_actions["View/HUD"], value.hud); }); } @@ -210,16 +210,16 @@ namespace toucan {} std::shared_ptr ViewMenu::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new ViewMenu); out->_init(context, app, parent); return out; } - const std::map >& ViewMenu::getActions() const + const std::map >& ViewMenu::getActions() const { return _actions; } @@ -229,44 +229,44 @@ namespace toucan const bool file = _file.get(); if (file) { - _frameViewObserver = dtk::ValueObserver::create( + _frameViewObserver = feather_tk::ValueObserver::create( _file->getViewModel()->observeFrameView(), [this](bool value) { - setItemChecked(_actions["View/Frame"], value); + setChecked(_actions["View/Frame"], value); }); - _optionsObserver = dtk::ValueObserver::create( + _optionsObserver = feather_tk::ValueObserver::create( _file->getViewModel()->observeOptions(), [this](const ViewOptions& value) { - setItemChecked(_actions["View/Flip"], value.flip); - setItemChecked(_actions["View/Flop"], value.flop); - setItemChecked(_actions["View/Red"], dtk::ChannelDisplay::Red == value.channelDisplay); - setItemChecked(_actions["View/Green"], dtk::ChannelDisplay::Green == value.channelDisplay); - setItemChecked(_actions["View/Blue"], dtk::ChannelDisplay::Blue == value.channelDisplay); - setItemChecked(_actions["View/Alpha"], dtk::ChannelDisplay::Alpha == value.channelDisplay); + setChecked(_actions["View/Flip"], value.flip); + setChecked(_actions["View/Flop"], value.flop); + setChecked(_actions["View/Red"], feather_tk::ChannelDisplay::Red == value.channelDisplay); + setChecked(_actions["View/Green"], feather_tk::ChannelDisplay::Green == value.channelDisplay); + setChecked(_actions["View/Blue"], feather_tk::ChannelDisplay::Blue == value.channelDisplay); + setChecked(_actions["View/Alpha"], feather_tk::ChannelDisplay::Alpha == value.channelDisplay); }); } else { - setItemChecked(_actions["View/Frame"], false); - setItemChecked(_actions["View/Flip"], false); - setItemChecked(_actions["View/Flop"], false); + setChecked(_actions["View/Frame"], false); + setChecked(_actions["View/Flip"], false); + setChecked(_actions["View/Flop"], false); _frameViewObserver.reset(); _optionsObserver.reset(); } - setItemEnabled(_actions["View/ZoomIn"], file); - setItemEnabled(_actions["View/ZoomOut"], file); - setItemEnabled(_actions["View/ZoomReset"], file); - setItemEnabled(_actions["View/Frame"], file); - setItemEnabled(_actions["View/Flip"], file); - setItemEnabled(_actions["View/Flop"], file); - setItemEnabled(_actions["View/Red"], file); - setItemEnabled(_actions["View/Green"], file); - setItemEnabled(_actions["View/Blue"], file); - setItemEnabled(_actions["View/Alpha"], file); - setItemEnabled(_actions["View/HUD"], file); + setEnabled(_actions["View/ZoomIn"], file); + setEnabled(_actions["View/ZoomOut"], file); + setEnabled(_actions["View/ZoomReset"], file); + setEnabled(_actions["View/Frame"], file); + setEnabled(_actions["View/Flip"], file); + setEnabled(_actions["View/Flop"], file); + setEnabled(_actions["View/Red"], file); + setEnabled(_actions["View/Green"], file); + setEnabled(_actions["View/Blue"], file); + setEnabled(_actions["View/Alpha"], file); + setEnabled(_actions["View/HUD"], file); } } diff --git a/lib/toucanView/ViewMenu.h b/lib/toucanView/ViewMenu.h index 4614c56..48615b5 100644 --- a/lib/toucanView/ViewMenu.h +++ b/lib/toucanView/ViewMenu.h @@ -5,8 +5,8 @@ #include -#include -#include +#include +#include namespace toucan { @@ -14,11 +14,11 @@ namespace toucan class File; //! View menu. - class ViewMenu : public dtk::Menu + class ViewMenu : public feather_tk::Menu { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -27,24 +27,24 @@ namespace toucan //! Create a new menu. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Get the actions. - const std::map >& getActions() const; + const std::map >& getActions() const; private: void _menuUpdate(); std::shared_ptr _file; - std::map > _actions; + std::map > _actions; - std::shared_ptr > > _fileObserver; - std::shared_ptr > _frameViewObserver; - std::shared_ptr > _optionsObserver; - std::shared_ptr > _globalOptionsObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > _frameViewObserver; + std::shared_ptr > _optionsObserver; + std::shared_ptr > _globalOptionsObserver; }; } diff --git a/lib/toucanView/ViewModel.cpp b/lib/toucanView/ViewModel.cpp index c19914b..124b465 100644 --- a/lib/toucanView/ViewModel.cpp +++ b/lib/toucanView/ViewModel.cpp @@ -3,8 +3,8 @@ #include "ViewModel.h" -#include -#include +#include +#include #include @@ -25,13 +25,13 @@ namespace toucan return !(*this == other); } - ViewModel::ViewModel(const std::shared_ptr& context) + ViewModel::ViewModel(const std::shared_ptr& context) { - _zoomIn = dtk::ObservableValue::create(false); - _zoomOut = dtk::ObservableValue::create(false); - _zoomReset = dtk::ObservableValue::create(false); - _frameView = dtk::ObservableValue::create(true); - _options = dtk::ObservableValue::create(); + _zoomIn = feather_tk::ObservableValue::create(false); + _zoomOut = feather_tk::ObservableValue::create(false); + _zoomReset = feather_tk::ObservableValue::create(false); + _frameView = feather_tk::ObservableValue::create(true); + _options = feather_tk::ObservableValue::create(); } ViewModel::~ViewModel() @@ -52,17 +52,17 @@ namespace toucan _zoomReset->setAlways(true); } - std::shared_ptr > ViewModel::observeZoomIn() const + std::shared_ptr > ViewModel::observeZoomIn() const { return _zoomIn; } - std::shared_ptr > ViewModel::observeZoomOut() const + std::shared_ptr > ViewModel::observeZoomOut() const { return _zoomOut; } - std::shared_ptr > ViewModel::observeZoomReset() const + std::shared_ptr > ViewModel::observeZoomReset() const { return _zoomReset; } @@ -72,7 +72,7 @@ namespace toucan return _frameView->get(); } - std::shared_ptr > ViewModel::observeFrameView() const + std::shared_ptr > ViewModel::observeFrameView() const { return _frameView; } @@ -87,7 +87,7 @@ namespace toucan return _options->get(); } - std::shared_ptr > ViewModel::observeOptions() const + std::shared_ptr > ViewModel::observeOptions() const { return _options; } @@ -97,7 +97,7 @@ namespace toucan _options->setIfChanged(value); } - DTK_ENUM_IMPL( + FEATHER_TK_ENUM_IMPL( ViewBackground, "Solid", "Checkers"); @@ -118,13 +118,16 @@ namespace toucan return !(*this == other); } - GlobalViewModel::GlobalViewModel(const std::shared_ptr& context) + GlobalViewModel::GlobalViewModel( + const std::shared_ptr& context, + const std::shared_ptr& settings) : + _settings(settings) { - _settings = context->getSystem(); GlobalViewOptions options; try { - const auto json = std::any_cast(_settings->get("GlobalViewModel")); + nlohmann::json json; + _settings->get("/GlobalViewModel", json); auto i = json.find("HUD"); if (i != json.end() && i->is_boolean()) { @@ -139,7 +142,7 @@ namespace toucan i = json.find("SolidColor"); if (i != json.end() && i->is_array() && 4 == i->size()) { - options.solidColor = dtk::Color4F( + options.solidColor = feather_tk::Color4F( (*i)[0].get(), (*i)[1].get(), (*i)[2].get(), @@ -148,7 +151,7 @@ namespace toucan i = json.find("CheckersColor0"); if (i != json.end() && i->is_array() && 4 == i->size()) { - options.checkersColor0 = dtk::Color4F( + options.checkersColor0 = feather_tk::Color4F( (*i)[0].get(), (*i)[1].get(), (*i)[2].get(), @@ -157,7 +160,7 @@ namespace toucan i = json.find("CheckersColor1"); if (i != json.end() && i->is_array() && 4 == i->size()) { - options.checkersColor1 = dtk::Color4F( + options.checkersColor1 = feather_tk::Color4F( (*i)[0].get(), (*i)[1].get(), (*i)[2].get(), @@ -172,7 +175,7 @@ namespace toucan catch (const std::exception&) {} - _options = dtk::ObservableValue::create(options); + _options = feather_tk::ObservableValue::create(options); } GlobalViewModel::~GlobalViewModel() @@ -206,7 +209,7 @@ namespace toucan _options->get().checkersColor1.a }; json["CheckersSize"] = _options->get().checkersSize; - _settings->set("GlobalViewModel", json); + _settings->set("/GlobalViewModel", json); } const GlobalViewOptions& GlobalViewModel::getOptions() const @@ -214,7 +217,7 @@ namespace toucan return _options->get(); } - std::shared_ptr > GlobalViewModel::observeOptions() const + std::shared_ptr > GlobalViewModel::observeOptions() const { return _options; } diff --git a/lib/toucanView/ViewModel.h b/lib/toucanView/ViewModel.h index dc6ff45..2ae41b8 100644 --- a/lib/toucanView/ViewModel.h +++ b/lib/toucanView/ViewModel.h @@ -3,10 +3,10 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -17,7 +17,7 @@ namespace toucan { bool flip = false; bool flop = false; - dtk::ChannelDisplay channelDisplay = dtk::ChannelDisplay::Color; + feather_tk::ChannelDisplay channelDisplay = feather_tk::ChannelDisplay::Color; bool operator == (const ViewOptions&) const; bool operator != (const ViewOptions&) const; @@ -27,7 +27,7 @@ namespace toucan class ViewModel : public std::enable_shared_from_this { public: - ViewModel(const std::shared_ptr&); + ViewModel(const std::shared_ptr&); virtual ~ViewModel(); @@ -41,19 +41,19 @@ namespace toucan void zoomReset(); //! Observe the zoom in. - std::shared_ptr > observeZoomIn() const; + std::shared_ptr > observeZoomIn() const; //! Observe the zoom out. - std::shared_ptr > observeZoomOut() const; + std::shared_ptr > observeZoomOut() const; //! Observe the zoom reset. - std::shared_ptr > observeZoomReset() const; + std::shared_ptr > observeZoomReset() const; //! Get whether frame view is enabled. bool getFrameView() const; //! Observe whether frame view is enabled. - std::shared_ptr > observeFrameView() const; + std::shared_ptr > observeFrameView() const; //! Set whether frame view is enabled. void setFrameView(bool); @@ -62,17 +62,17 @@ namespace toucan const ViewOptions& getOptions() const; //! Observe the view options. - std::shared_ptr > observeOptions() const; + std::shared_ptr > observeOptions() const; //! Set the view options. void setOptions(const ViewOptions&); private: - std::shared_ptr > _zoomIn; - std::shared_ptr > _zoomOut; - std::shared_ptr > _zoomReset; - std::shared_ptr > _frameView; - std::shared_ptr > _options; + std::shared_ptr > _zoomIn; + std::shared_ptr > _zoomOut; + std::shared_ptr > _zoomReset; + std::shared_ptr > _frameView; + std::shared_ptr > _options; }; //! View background options. @@ -84,16 +84,16 @@ namespace toucan Count, First = Solid }; - DTK_ENUM(ViewBackground); + FEATHER_TK_ENUM(ViewBackground); //! Global view options. struct GlobalViewOptions { bool hud = false; ViewBackground background = ViewBackground::Solid; - dtk::Color4F solidColor = dtk::Color4F(0.F, 0.F, 0.F, 1.F); - dtk::Color4F checkersColor0 = dtk::Color4F(0.F, 0.F, 0.F, 1.F); - dtk::Color4F checkersColor1 = dtk::Color4F(1.F, 1.F, 1.F, 1.F); + feather_tk::Color4F solidColor = feather_tk::Color4F(0.F, 0.F, 0.F, 1.F); + feather_tk::Color4F checkersColor0 = feather_tk::Color4F(0.F, 0.F, 0.F, 1.F); + feather_tk::Color4F checkersColor1 = feather_tk::Color4F(1.F, 1.F, 1.F, 1.F); int checkersSize = 50; bool operator == (const GlobalViewOptions&) const; @@ -104,7 +104,9 @@ namespace toucan class GlobalViewModel : public std::enable_shared_from_this { public: - GlobalViewModel(const std::shared_ptr&); + GlobalViewModel( + const std::shared_ptr&, + const std::shared_ptr&); virtual ~GlobalViewModel(); @@ -112,13 +114,13 @@ namespace toucan const GlobalViewOptions& getOptions() const; //! Observe the view options. - std::shared_ptr > observeOptions() const; + std::shared_ptr > observeOptions() const; //! Set the view options. void setOptions(const GlobalViewOptions&); private: - std::shared_ptr _settings; - std::shared_ptr > _options; + std::shared_ptr _settings; + std::shared_ptr > _options; }; } diff --git a/lib/toucanView/ViewToolBar.cpp b/lib/toucanView/ViewToolBar.cpp index 196410e..a647b46 100644 --- a/lib/toucanView/ViewToolBar.cpp +++ b/lib/toucanView/ViewToolBar.cpp @@ -10,18 +10,18 @@ namespace toucan { void ViewToolBar::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::map >& actions, - const std::shared_ptr& parent) + const std::map >& actions, + const std::shared_ptr& parent) { - dtk::IWidget::_init(context, "toucan::ViewToolBar", parent); + feather_tk::IWidget::_init(context, "toucan::ViewToolBar", parent); - _layout = dtk::HorizontalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingSmall); + _layout = feather_tk::HorizontalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); - auto hLayout = dtk::HorizontalLayout::create(context, _layout); - hLayout->setSpacingRole(dtk::SizeRole::SpacingTool); + auto hLayout = feather_tk::HorizontalLayout::create(context, _layout); + hLayout->setSpacingRole(feather_tk::SizeRole::SpacingTool); std::vector actionNames = { "View/ZoomIn", @@ -31,38 +31,17 @@ namespace toucan for (const auto& name : actionNames) { auto i = actions.find(name); - auto button = dtk::ToolButton::create(context, hLayout); - button->setIcon(i->second->icon); - button->setTooltip(i->second->toolTip); - button->setClickedCallback( - [i] - { - if (i->second->callback) - { - i->second->callback(); - } - }); + auto button = feather_tk::ToolButton::create(context, i->second, hLayout); _buttons[name] = button; } auto i = actions.find("View/Frame"); - auto button = dtk::ToolButton::create(context, hLayout); - button->setIcon(i->second->icon); - button->setCheckable(true); - button->setTooltip(i->second->toolTip); - button->setCheckedCallback( - [i](bool value) - { - if (i->second->checkedCallback) - { - i->second->checkedCallback(value); - } - }); + auto button = feather_tk::ToolButton::create(context, i->second, hLayout); _buttons["View/Frame"] = button; _widgetUpdate(); - _filesObserver = dtk::ListObserver >::create( + _filesObserver = feather_tk::ListObserver >::create( app->getFilesModel()->observeFiles(), [this](const std::vector >& files) { @@ -70,7 +49,7 @@ namespace toucan _widgetUpdate(); }); - _fileObserver = dtk::ValueObserver >::create( + _fileObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeCurrent(), [this](const std::shared_ptr& file) { @@ -83,23 +62,23 @@ namespace toucan {} std::shared_ptr ViewToolBar::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, - const std::map >& actions, - const std::shared_ptr& parent) + const std::map >& actions, + const std::shared_ptr& parent) { auto out = std::shared_ptr(new ViewToolBar); out->_init(context, app, actions, parent); return out; } - void ViewToolBar::setGeometry(const dtk::Box2I& value) + void ViewToolBar::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void ViewToolBar::sizeHintEvent(const dtk::SizeHintEvent& event) + void ViewToolBar::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); @@ -114,7 +93,7 @@ namespace toucan if (_file) { - _frameViewObserver = dtk::ValueObserver::create( + _frameViewObserver = feather_tk::ValueObserver::create( _file->getViewModel()->observeFrameView(), [this](bool value) { diff --git a/lib/toucanView/ViewToolBar.h b/lib/toucanView/ViewToolBar.h index 1b7d6c1..5ee4b85 100644 --- a/lib/toucanView/ViewToolBar.h +++ b/lib/toucanView/ViewToolBar.h @@ -3,10 +3,10 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include namespace toucan { @@ -14,13 +14,13 @@ namespace toucan class File; //! View tool bar. - class ViewToolBar : public dtk::IWidget + class ViewToolBar : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, - const std::map >&, + const std::map >&, const std::shared_ptr& parent); public: @@ -28,13 +28,13 @@ namespace toucan //! Create a new tool bar. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, - const std::map >&, + const std::map >&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: void _widgetUpdate(); @@ -42,12 +42,12 @@ namespace toucan size_t _filesSize = 0; std::shared_ptr _file; - std::shared_ptr _layout; - std::map > _buttons; + std::shared_ptr _layout; + std::map > _buttons; - std::shared_ptr > > _filesObserver; - std::shared_ptr > > _fileObserver; - std::shared_ptr > _frameViewObserver; + std::shared_ptr > > _filesObserver; + std::shared_ptr > > _fileObserver; + std::shared_ptr > _frameViewObserver; }; } diff --git a/lib/toucanView/Viewport.cpp b/lib/toucanView/Viewport.cpp index 9bd036e..6971c28 100644 --- a/lib/toucanView/Viewport.cpp +++ b/lib/toucanView/Viewport.cpp @@ -8,15 +8,15 @@ #include "App.h" #include "ViewModel.h" -#include +#include namespace toucan { void Viewport::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& file, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { IWidget::_init(context, "toucan::Viewport", parent); @@ -26,19 +26,19 @@ namespace toucan _viewModel = file->getViewModel(); _imageSize.w = file->getImageSize().x; _imageSize.h = file->getImageSize().y; - _viewPos = dtk::ObservableValue::create(); - _viewZoom = dtk::ObservableValue::create(1.F); - _frameView = dtk::ObservableValue::create(true); + _viewPos = feather_tk::ObservableValue::create(); + _viewZoom = feather_tk::ObservableValue::create(1.F); + _frameView = feather_tk::ObservableValue::create(true); - _imageObserver = dtk::ValueObserver >::create( + _imageObserver = feather_tk::ValueObserver >::create( file->observeCurrentImage(), - [this](const std::shared_ptr& value) + [this](const std::shared_ptr& value) { _image = value; _setDrawUpdate(); }); - _bObserver = dtk::ValueObserver >::create( + _bObserver = feather_tk::ValueObserver >::create( app->getFilesModel()->observeBFile(), [this](const std::shared_ptr& value) { @@ -47,9 +47,9 @@ namespace toucan const auto& imageSize = value->getImageSize(); _bImageSize.w = imageSize.x; _bImageSize.h = imageSize.y; - _bImageObserver = dtk::ValueObserver >::create( + _bImageObserver = feather_tk::ValueObserver >::create( value->observeCurrentImage(), - [this](const std::shared_ptr& value) + [this](const std::shared_ptr& value) { _bImage = value; _setDrawUpdate(); @@ -57,14 +57,14 @@ namespace toucan } else { - _bImageSize = dtk::Size2I(); + _bImageSize = feather_tk::Size2I(); _bImage.reset(); _bImageObserver.reset(); _setDrawUpdate(); } }); - _compareOptionsObserver = dtk::ValueObserver::create( + _compareOptionsObserver = feather_tk::ValueObserver::create( app->getFilesModel()->observeCompareOptions(), [this](const CompareOptions& value) { @@ -72,7 +72,7 @@ namespace toucan _setDrawUpdate(); }); - _zoomInObserver = dtk::ValueObserver::create( + _zoomInObserver = feather_tk::ValueObserver::create( _viewModel->observeZoomIn(), [this](bool value) { @@ -82,7 +82,7 @@ namespace toucan } }); - _zoomOutObserver = dtk::ValueObserver::create( + _zoomOutObserver = feather_tk::ValueObserver::create( _viewModel->observeZoomOut(), [this](bool value) { @@ -92,7 +92,7 @@ namespace toucan } }); - _zoomResetObserver = dtk::ValueObserver::create( + _zoomResetObserver = feather_tk::ValueObserver::create( _viewModel->observeZoomReset(), [this](bool value) { @@ -102,14 +102,14 @@ namespace toucan } }); - _frameObserver = dtk::ValueObserver::create( + _frameObserver = feather_tk::ValueObserver::create( _viewModel->observeFrameView(), [this](bool value) { setFrameView(value); }); - _optionsObserver = dtk::ValueObserver::create( + _optionsObserver = feather_tk::ValueObserver::create( _viewModel->observeOptions(), [this](const ViewOptions& value) { @@ -117,7 +117,7 @@ namespace toucan _setDrawUpdate(); }); - _globalOptionsObserver = dtk::ValueObserver::create( + _globalOptionsObserver = feather_tk::ValueObserver::create( app->getGlobalViewModel()->observeOptions(), [this](const GlobalViewOptions& value) { @@ -130,17 +130,17 @@ namespace toucan {} std::shared_ptr Viewport::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& file, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new Viewport); out->_init(context, app, file, parent); return out; } - const dtk::V2I& Viewport::getViewPos() const + const feather_tk::V2I& Viewport::getViewPos() const { return _viewPos->get(); } @@ -150,17 +150,17 @@ namespace toucan return _viewZoom->get(); } - std::shared_ptr > Viewport::observeViewPos() const + std::shared_ptr > Viewport::observeViewPos() const { return _viewPos; } - std::shared_ptr > Viewport::observeViewZoom() const + std::shared_ptr > Viewport::observeViewZoom() const { return _viewZoom; } - void Viewport::setViewPosZoom(const dtk::V2I& pos, float zoom) + void Viewport::setViewPosZoom(const feather_tk::V2I& pos, float zoom) { setFrameView(false); bool changed = _viewPos->setIfChanged(pos); @@ -173,14 +173,14 @@ namespace toucan void Viewport::setViewZoom(float value) { - const dtk::Box2I& g = getGeometry(); - const dtk::V2I viewportCenter(g.w() / 2, g.h() / 2); + const feather_tk::Box2I& g = getGeometry(); + const feather_tk::V2I viewportCenter(g.w() / 2, g.h() / 2); setViewZoom(value, _isMouseInside() ? (_getMousePos() - g.min) : viewportCenter); } - void Viewport::setViewZoom(float zoom, const dtk::V2I& focus) + void Viewport::setViewZoom(float zoom, const feather_tk::V2I& focus) { - dtk::V2I pos = _viewPos->get(); + feather_tk::V2I pos = _viewPos->get(); const float zoomPrev = _viewZoom->get(); pos.x = focus.x + (pos.x - focus.x) * (zoom / zoomPrev); pos.y = focus.y + (pos.y - focus.y) * (zoom / zoomPrev); @@ -207,7 +207,7 @@ namespace toucan return _frameView->get(); } - std::shared_ptr > Viewport::observeFrameView() const + std::shared_ptr > Viewport::observeFrameView() const { return _frameView; } @@ -221,23 +221,23 @@ namespace toucan } } - void Viewport::drawEvent(const dtk::Box2I& drawRect, const dtk::DrawEvent& event) + void Viewport::drawEvent(const feather_tk::Box2I& drawRect, const feather_tk::DrawEvent& event) { IWidget::drawEvent(drawRect, event); // Draw the background. - const dtk::Box2I& g = getGeometry(); + const feather_tk::Box2I& g = getGeometry(); switch (_globalOptions.background) { case ViewBackground::Solid: event.render->drawRect(g, _globalOptions.solidColor); break; case ViewBackground::Checkers: - event.render->drawColorMesh(dtk::checkers( + event.render->drawColorMesh(feather_tk::checkers( g, _globalOptions.checkersColor0, _globalOptions.checkersColor1, - dtk::Size2I(_globalOptions.checkersSize, _globalOptions.checkersSize))); + feather_tk::Size2I(_globalOptions.checkersSize, _globalOptions.checkersSize))); break; default: break; } @@ -247,10 +247,10 @@ namespace toucan { _frameUpdate(); } - dtk::M44F vm; - vm = vm * dtk::translate(dtk::V3F(g.min.x, g.min.y, 0.F)); - vm = vm * dtk::translate(dtk::V3F(_viewPos->get().x, _viewPos->get().y, 0.F)); - vm = vm * dtk::scale(dtk::V3F(_viewZoom->get(), _viewZoom->get(), 1.F)); + feather_tk::M44F vm; + vm = vm * feather_tk::translate(feather_tk::V3F(g.min.x, g.min.y, 0.F)); + vm = vm * feather_tk::translate(feather_tk::V3F(_viewPos->get().x, _viewPos->get().y, 0.F)); + vm = vm * feather_tk::scale(feather_tk::V3F(_viewZoom->get(), _viewZoom->get(), 1.F)); const auto m = event.render->getTransform(); event.render->setTransform(m * vm); @@ -276,9 +276,9 @@ namespace toucan { bImageBox = fit(imageSize, bImageSize); } - dtk::ImageOptions options; + feather_tk::ImageOptions options; options.channelDisplay = _options.channelDisplay; - options.imageFilters.magnify = dtk::ImageFilter::Nearest; + options.imageFilters.magnify = feather_tk::ImageFilter::Nearest; switch (_compareOptions.mode) { case CompareMode::A: @@ -286,8 +286,8 @@ namespace toucan { event.render->drawImage( _image, - _getMesh(dtk::Box2I(0, 0, imageSize.x, imageSize.y)), - dtk::Color4F(1.F, 1.F, 1.F), + _getMesh(feather_tk::Box2I(0, 0, imageSize.x, imageSize.y)), + feather_tk::Color4F(1.F, 1.F, 1.F), options); } break; @@ -296,29 +296,29 @@ namespace toucan { event.render->drawImage( _bImage, - _getMesh(dtk::Box2I( + _getMesh(feather_tk::Box2I( bImageBox.min.x, bImageBox.min.y, bImageBox.max.x - bImageBox.min.x + 1, bImageBox.max.y - bImageBox.min.y + 1)), - dtk::Color4F(1.F, 1.F, 1.F), + feather_tk::Color4F(1.F, 1.F, 1.F), options); } break; case CompareMode::Split: if (_image) { - dtk::TriMesh2F mesh; - dtk::Box2I box(0, 0, imageSize.x / 2, imageSize.y); - mesh.v.push_back(dtk::V2F(box.min.x, box.min.y)); - mesh.v.push_back(dtk::V2F(box.max.x + 1, box.min.y)); - mesh.v.push_back(dtk::V2F(box.max.x + 1, box.max.y + 1)); - mesh.v.push_back(dtk::V2F(box.min.x, box.max.y + 1)); - mesh.t.push_back(dtk::V2F(_options.flop ? 1.F : 0.F, _options.flip ? 1.F : 0.F)); - mesh.t.push_back(dtk::V2F(_options.flop ? .5F : .5F, _options.flip ? 1.F : 0.F)); - mesh.t.push_back(dtk::V2F(_options.flop ? .5F : .5F, _options.flip ? 0.F : 1.F)); - mesh.t.push_back(dtk::V2F(_options.flop ? 1.F : 0.F, _options.flip ? 0.F : 1.F)); - dtk::Triangle2 triangle; + feather_tk::TriMesh2F mesh; + feather_tk::Box2I box(0, 0, imageSize.x / 2, imageSize.y); + mesh.v.push_back(feather_tk::V2F(box.min.x, box.min.y)); + mesh.v.push_back(feather_tk::V2F(box.max.x + 1, box.min.y)); + mesh.v.push_back(feather_tk::V2F(box.max.x + 1, box.max.y + 1)); + mesh.v.push_back(feather_tk::V2F(box.min.x, box.max.y + 1)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? 1.F : 0.F, _options.flip ? 1.F : 0.F)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? .5F : .5F, _options.flip ? 1.F : 0.F)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? .5F : .5F, _options.flip ? 0.F : 1.F)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? 1.F : 0.F, _options.flip ? 0.F : 1.F)); + feather_tk::Triangle2 triangle; triangle.v[0].v = 1; triangle.v[1].v = 2; triangle.v[2].v = 3; @@ -336,26 +336,26 @@ namespace toucan event.render->drawImage( _image, mesh, - dtk::Color4F(1.F, 1.F, 1.F), + feather_tk::Color4F(1.F, 1.F, 1.F), options); } if (_bImage) { - dtk::TriMesh2F mesh; - dtk::Box2I box( + feather_tk::TriMesh2F mesh; + feather_tk::Box2I box( imageSize.x / 2, bImageBox.min.y, (bImageBox.max.x - bImageBox.min.x + 1) / 2, bImageBox.max.y - bImageBox.min.y + 1); - mesh.v.push_back(dtk::V2F(box.min.x, box.min.y)); - mesh.v.push_back(dtk::V2F(box.max.x + 1, box.min.y)); - mesh.v.push_back(dtk::V2F(box.max.x + 1, box.max.y + 1)); - mesh.v.push_back(dtk::V2F(box.min.x, box.max.y + 1)); - mesh.t.push_back(dtk::V2F(_options.flop ? .5F : .5F, _options.flip ? 1.F : 0.F)); - mesh.t.push_back(dtk::V2F(_options.flop ? 0.F : 1.F, _options.flip ? 1.F : 0.F)); - mesh.t.push_back(dtk::V2F(_options.flop ? 0.F : 1.F, _options.flip ? 0.F : 1.F)); - mesh.t.push_back(dtk::V2F(_options.flop ? .5F : .5F, _options.flip ? 0.F : 1.F)); - dtk::Triangle2 triangle; + mesh.v.push_back(feather_tk::V2F(box.min.x, box.min.y)); + mesh.v.push_back(feather_tk::V2F(box.max.x + 1, box.min.y)); + mesh.v.push_back(feather_tk::V2F(box.max.x + 1, box.max.y + 1)); + mesh.v.push_back(feather_tk::V2F(box.min.x, box.max.y + 1)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? .5F : .5F, _options.flip ? 1.F : 0.F)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? 0.F : 1.F, _options.flip ? 1.F : 0.F)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? 0.F : 1.F, _options.flip ? 0.F : 1.F)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? .5F : .5F, _options.flip ? 0.F : 1.F)); + feather_tk::Triangle2 triangle; triangle.v[0].v = 1; triangle.v[1].v = 2; triangle.v[2].v = 3; @@ -373,7 +373,7 @@ namespace toucan event.render->drawImage( _bImage, mesh, - dtk::Color4F(1.F, 1.F, 1.F), + feather_tk::Color4F(1.F, 1.F, 1.F), options); } break; @@ -382,37 +382,37 @@ namespace toucan { event.render->drawImage( _image, - _getMesh(dtk::Box2I(0, 0, imageSize.x, imageSize.y)), - dtk::Color4F(1.F, 1.F, 1.F), + _getMesh(feather_tk::Box2I(0, 0, imageSize.x, imageSize.y)), + feather_tk::Color4F(1.F, 1.F, 1.F), options); event.render->drawImage( _bImage, - _getMesh(dtk::Box2I( + _getMesh(feather_tk::Box2I( bImageBox.min.x, bImageBox.min.y, bImageBox.max.x - bImageBox.min.x + 1, bImageBox.max.y - bImageBox.min.y + 1)), - dtk::Color4F(1.F, 1.F, 1.F, .5F), + feather_tk::Color4F(1.F, 1.F, 1.F, .5F), options); } else if (_image) { event.render->drawImage( _image, - _getMesh(dtk::Box2I(0, 0, imageSize.x, imageSize.y)), - dtk::Color4F(1.F, 1.F, 1.F), + _getMesh(feather_tk::Box2I(0, 0, imageSize.x, imageSize.y)), + feather_tk::Color4F(1.F, 1.F, 1.F), options); } else if (_bImage) { event.render->drawImage( _bImage, - _getMesh(dtk::Box2I( + _getMesh(feather_tk::Box2I( bImageBox.min.x, bImageBox.min.y, bImageBox.max.x - bImageBox.min.x + 1, bImageBox.max.y - bImageBox.min.y + 1)), - dtk::Color4F(1.F, 1.F, 1.F), + feather_tk::Color4F(1.F, 1.F, 1.F), options); } break; @@ -423,8 +423,8 @@ namespace toucan { event.render->drawImage( _image, - _getMesh(dtk::Box2I(0, 0, imageSize.x, imageSize.y)), - dtk::Color4F(1.F, 1.F, 1.F), + _getMesh(feather_tk::Box2I(0, 0, imageSize.x, imageSize.y)), + feather_tk::Color4F(1.F, 1.F, 1.F), options); x += _image->getWidth(); } @@ -432,12 +432,12 @@ namespace toucan { event.render->drawImage( _bImage, - _getMesh(dtk::Box2I( + _getMesh(feather_tk::Box2I( x + bImageBox.min.x, bImageBox.min.y, bImageBox.max.x - bImageBox.min.x + 1, bImageBox.max.y - bImageBox.min.y + 1)), - dtk::Color4F(1.F, 1.F, 1.F), + feather_tk::Color4F(1.F, 1.F, 1.F), options); } break; @@ -449,8 +449,8 @@ namespace toucan { event.render->drawImage( _image, - _getMesh(dtk::Box2I(0, 0, _image->getWidth(), _image->getHeight())), - dtk::Color4F(1.F, 1.F, 1.F), + _getMesh(feather_tk::Box2I(0, 0, _image->getWidth(), _image->getHeight())), + feather_tk::Color4F(1.F, 1.F, 1.F), options); y += _image->getHeight(); } @@ -458,12 +458,12 @@ namespace toucan { event.render->drawImage( _bImage, - _getMesh(dtk::Box2I( + _getMesh(feather_tk::Box2I( bImageBox.min.x, y + bImageBox.min.y, bImageBox.max.x - bImageBox.min.x + 1, bImageBox.max.y - bImageBox.min.y + 1)), - dtk::Color4F(1.F, 1.F, 1.F), + feather_tk::Color4F(1.F, 1.F, 1.F), options); } break; @@ -475,21 +475,21 @@ namespace toucan event.render->setTransform(m); } - void Viewport::mouseMoveEvent(dtk::MouseMoveEvent& event) + void Viewport::mouseMoveEvent(feather_tk::MouseMoveEvent& event) { IWidget::mouseMoveEvent(event); if (_isMousePressed()) { event.accept = true; - const dtk::V2I& mousePressPos = _getMousePressPos(); - _viewPos->setIfChanged(dtk::V2I( + const feather_tk::V2I& mousePressPos = _getMousePressPos(); + _viewPos->setIfChanged(feather_tk::V2I( _viewMousePress.x + (event.pos.x - mousePressPos.x), _viewMousePress.y + (event.pos.y - mousePressPos.y))); _setDrawUpdate(); } } - void Viewport::mousePressEvent(dtk::MouseClickEvent& event) + void Viewport::mousePressEvent(feather_tk::MouseClickEvent& event) { IWidget::mousePressEvent(event); if (0 == event.button && 0 == event.modifiers) @@ -500,13 +500,13 @@ namespace toucan } } - void Viewport::mouseReleaseEvent(dtk::MouseClickEvent& event) + void Viewport::mouseReleaseEvent(feather_tk::MouseClickEvent& event) { IWidget::mouseReleaseEvent(event); event.accept = true; } - void Viewport::scrollEvent(dtk::ScrollEvent& event) + void Viewport::scrollEvent(feather_tk::ScrollEvent& event) { IWidget::scrollEvent(event); if (0 == event.modifiers) @@ -523,10 +523,10 @@ namespace toucan } } - dtk::Size2I Viewport::_getSize() const + feather_tk::Size2I Viewport::_getSize() const { - dtk::Size2I out = _imageSize; - const dtk::Size2I bImageSize = _compareOptions.resize ? _imageSize : _bImageSize; + feather_tk::Size2I out = _imageSize; + const feather_tk::Size2I bImageSize = _compareOptions.resize ? _imageSize : _bImageSize; switch (_compareOptions.mode) { case CompareMode::B: @@ -545,18 +545,18 @@ namespace toucan return out; } - dtk::TriMesh2F Viewport::_getMesh(const dtk::Box2I& box) const + feather_tk::TriMesh2F Viewport::_getMesh(const feather_tk::Box2I& box) const { - dtk::TriMesh2F mesh; - mesh.v.push_back(dtk::V2F(box.min.x, box.min.y)); - mesh.v.push_back(dtk::V2F(box.max.x + 1, box.min.y)); - mesh.v.push_back(dtk::V2F(box.max.x + 1, box.max.y + 1)); - mesh.v.push_back(dtk::V2F(box.min.x, box.max.y + 1)); - mesh.t.push_back(dtk::V2F(_options.flop ? 1.F : 0.F, _options.flip ? 1.F : 0.F)); - mesh.t.push_back(dtk::V2F(_options.flop ? 0.F : 1.F, _options.flip ? 1.F : 0.F)); - mesh.t.push_back(dtk::V2F(_options.flop ? 0.F : 1.F, _options.flip ? 0.F : 1.F)); - mesh.t.push_back(dtk::V2F(_options.flop ? 1.F : 0.F, _options.flip ? 0.F : 1.F)); - dtk::Triangle2 triangle; + feather_tk::TriMesh2F mesh; + mesh.v.push_back(feather_tk::V2F(box.min.x, box.min.y)); + mesh.v.push_back(feather_tk::V2F(box.max.x + 1, box.min.y)); + mesh.v.push_back(feather_tk::V2F(box.max.x + 1, box.max.y + 1)); + mesh.v.push_back(feather_tk::V2F(box.min.x, box.max.y + 1)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? 1.F : 0.F, _options.flip ? 1.F : 0.F)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? 0.F : 1.F, _options.flip ? 1.F : 0.F)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? 0.F : 1.F, _options.flip ? 0.F : 1.F)); + mesh.t.push_back(feather_tk::V2F(_options.flop ? 1.F : 0.F, _options.flip ? 0.F : 1.F)); + feather_tk::Triangle2 triangle; triangle.v[0].v = 1; triangle.v[1].v = 2; triangle.v[2].v = 3; @@ -578,15 +578,15 @@ namespace toucan { if (_frameView->get()) { - const dtk::Box2I& g = getGeometry(); - const dtk::Size2I size = _getSize(); + const feather_tk::Box2I& g = getGeometry(); + const feather_tk::Size2I size = _getSize(); float zoom = g.w() / static_cast(size.w); if (zoom * size.h > g.h()) { zoom = g.h() / static_cast(size.h); } - const dtk::V2I c(size.w / 2, size.h / 2); - const dtk::V2I pos = dtk::V2I( + const feather_tk::V2I c(size.w / 2, size.h / 2); + const feather_tk::V2I pos = feather_tk::V2I( g.w() / 2.F - c.x * zoom, g.h() / 2.F - c.y * zoom); diff --git a/lib/toucanView/Viewport.h b/lib/toucanView/Viewport.h index 33d720c..dcd03b3 100644 --- a/lib/toucanView/Viewport.h +++ b/lib/toucanView/Viewport.h @@ -6,9 +6,9 @@ #include #include -#include +#include -#include +#include namespace toucan { @@ -17,11 +17,11 @@ namespace toucan class ViewModel; //! Viewport widget. - class Viewport : public dtk::IWidget + class Viewport : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -31,31 +31,31 @@ namespace toucan //! Create a new widget. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Get the view position. - const dtk::V2I& getViewPos() const; + const feather_tk::V2I& getViewPos() const; //! Get the view zoom. float getViewZoom() const; //! Observe the view position. - std::shared_ptr > observeViewPos() const; + std::shared_ptr > observeViewPos() const; //! Observe the view zoom. - std::shared_ptr > observeViewZoom() const; + std::shared_ptr > observeViewZoom() const; //! Set the view position and zoom. - void setViewPosZoom(const dtk::V2I&, float); + void setViewPosZoom(const feather_tk::V2I&, float); //! Set the view zoom. void setViewZoom(float); //! Set the view zoom. - void setViewZoom(float, const dtk::V2I& focus); + void setViewZoom(float, const feather_tk::V2I& focus); //! Zoom in the view. void viewZoomIn(double amount = 2.F); @@ -70,46 +70,46 @@ namespace toucan bool getFrameView() const; //! Observe whether frame view is enabled. - std::shared_ptr > observeFrameView() const; + std::shared_ptr > observeFrameView() const; //! Set whether frame view is enabled. void setFrameView(bool); - void drawEvent(const dtk::Box2I&, const dtk::DrawEvent&) override; - void mouseMoveEvent(dtk::MouseMoveEvent&) override; - void mousePressEvent(dtk::MouseClickEvent&) override; - void mouseReleaseEvent(dtk::MouseClickEvent&) override; - void scrollEvent(dtk::ScrollEvent&) override; + void drawEvent(const feather_tk::Box2I&, const feather_tk::DrawEvent&) override; + void mouseMoveEvent(feather_tk::MouseMoveEvent&) override; + void mousePressEvent(feather_tk::MouseClickEvent&) override; + void mouseReleaseEvent(feather_tk::MouseClickEvent&) override; + void scrollEvent(feather_tk::ScrollEvent&) override; private: - dtk::Size2I _getSize() const; - dtk::TriMesh2F _getMesh(const dtk::Box2I&) const; + feather_tk::Size2I _getSize() const; + feather_tk::TriMesh2F _getMesh(const feather_tk::Box2I&) const; void _frameUpdate(); std::shared_ptr _viewModel; - dtk::Size2I _imageSize; - std::shared_ptr _image; - dtk::Size2I _bImageSize; - std::shared_ptr _bImage; + feather_tk::Size2I _imageSize; + std::shared_ptr _image; + feather_tk::Size2I _bImageSize; + std::shared_ptr _bImage; CompareOptions _compareOptions; - std::shared_ptr > _viewPos; - std::shared_ptr > _viewZoom; - std::shared_ptr > _frameView; + std::shared_ptr > _viewPos; + std::shared_ptr > _viewZoom; + std::shared_ptr > _frameView; ViewOptions _options; GlobalViewOptions _globalOptions; - dtk::V2I _viewMousePress; - - std::shared_ptr > > _imageObserver; - std::shared_ptr > > _bObserver; - std::shared_ptr > > _bImageObserver; - std::shared_ptr > _compareOptionsObserver; - std::shared_ptr > _zoomInObserver; - std::shared_ptr > _zoomOutObserver; - std::shared_ptr > _zoomResetObserver; - std::shared_ptr > _frameObserver; - std::shared_ptr > _optionsObserver; - std::shared_ptr > _globalOptionsObserver; + feather_tk::V2I _viewMousePress; + + std::shared_ptr > > _imageObserver; + std::shared_ptr > > _bObserver; + std::shared_ptr > > _bImageObserver; + std::shared_ptr > _compareOptionsObserver; + std::shared_ptr > _zoomInObserver; + std::shared_ptr > _zoomOutObserver; + std::shared_ptr > _zoomResetObserver; + std::shared_ptr > _frameObserver; + std::shared_ptr > _optionsObserver; + std::shared_ptr > _globalOptionsObserver; }; } diff --git a/lib/toucanView/WindowMenu.cpp b/lib/toucanView/WindowMenu.cpp index ad8948a..6e4c83e 100644 --- a/lib/toucanView/WindowMenu.cpp +++ b/lib/toucanView/WindowMenu.cpp @@ -11,27 +11,27 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include namespace toucan { void WindowMenu::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& window, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { - dtk::Menu::_init(context, parent); + feather_tk::Menu::_init(context, parent); std::weak_ptr windowWeak(window); - _actions["Window/FullScreen"] = std::make_shared( + _actions["Window/FullScreen"] = feather_tk::Action::create( "Full Screen", "WindowFullScreen", - dtk::Key::U, - static_cast(dtk::commandKeyModifier), + feather_tk::Key::U, + static_cast(feather_tk::commandKeyModifier), [windowWeak](bool value) { if (auto window = windowWeak.lock()) @@ -39,8 +39,8 @@ namespace toucan window->setFullScreen(value); } }); - _actions["Window/FullScreen"]->toolTip = "Toggle full screen mode"; - addItem(_actions["Window/FullScreen"]); + _actions["Window/FullScreen"]->setTooltip("Toggle full screen mode"); + addAction(_actions["Window/FullScreen"]); addDivider(); @@ -62,8 +62,8 @@ namespace toucan std::weak_ptr appWeak(app); for (const auto& component : components) { - const std::string actionName = dtk::Format("Window/{0}").arg(component.action); - _actions[actionName] = std::make_shared( + const std::string actionName = feather_tk::Format("Window/{0}").arg(component.action); + _actions[actionName] = feather_tk::Action::create( component.text, component.icon, [appWeak, component](bool value) @@ -73,50 +73,50 @@ namespace toucan app->getWindowModel()->setComponent(component.component, value); } }); - _actions[actionName]->toolTip = component.tooltip; - addItem(_actions[actionName]); + _actions[actionName]->setTooltip(component.tooltip); + addAction(_actions[actionName]); } addDivider(); _menus["Window/Resize"] = addSubMenu("Resize"); - _actions["Window/Resize/1280x720"] = std::make_shared( + _actions["Window/Resize/1280x720"] = feather_tk::Action::create( "1280x720", [windowWeak] { if (auto window = windowWeak.lock()) { - window->setSize(dtk::Size2I(1280, 720)); + window->setSize(feather_tk::Size2I(1280, 720)); } }); - _menus["Window/Resize"]->addItem(_actions["Window/Resize/1280x720"]); + _menus["Window/Resize"]->addAction(_actions["Window/Resize/1280x720"]); - _actions["Window/Resize/1920x1080"] = std::make_shared( + _actions["Window/Resize/1920x1080"] = feather_tk::Action::create( "1920x1080", [windowWeak] { if (auto window = windowWeak.lock()) { - window->setSize(dtk::Size2I(1920, 1080)); + window->setSize(feather_tk::Size2I(1920, 1080)); } }); - _menus["Window/Resize"]->addItem(_actions["Window/Resize/1920x1080"]); + _menus["Window/Resize"]->addAction(_actions["Window/Resize/1920x1080"]); - _actions["Window/Resize/3840x2160"] = std::make_shared( + _actions["Window/Resize/3840x2160"] = feather_tk::Action::create( "3840x2160", [windowWeak] { if (auto window = windowWeak.lock()) { - window->setSize(dtk::Size2I(3840, 2160)); + window->setSize(feather_tk::Size2I(3840, 2160)); } }); - _menus["Window/Resize"]->addItem(_actions["Window/Resize/3840x2160"]); + _menus["Window/Resize"]->addAction(_actions["Window/Resize/3840x2160"]); _menus["Window/DisplayScale"] = addSubMenu("Display Scale"); - _actions["Window/DisplayScale/Auto"] = std::make_shared( + _actions["Window/DisplayScale/Auto"] = feather_tk::Action::create( "Automatic", [windowWeak](bool value) { @@ -125,9 +125,9 @@ namespace toucan window->setDisplayScale(0.F); } }); - _menus["Window/DisplayScale"]->addItem(_actions["Window/DisplayScale/Auto"]); + _menus["Window/DisplayScale"]->addAction(_actions["Window/DisplayScale/Auto"]); - _actions["Window/DisplayScale/1.0"] = std::make_shared( + _actions["Window/DisplayScale/1.0"] = feather_tk::Action::create( "1.0", [windowWeak](bool value) { @@ -136,9 +136,9 @@ namespace toucan window->setDisplayScale(1.F); } }); - _menus["Window/DisplayScale"]->addItem(_actions["Window/DisplayScale/1.0"]); + _menus["Window/DisplayScale"]->addAction(_actions["Window/DisplayScale/1.0"]); - _actions["Window/DisplayScale/1.5"] = std::make_shared( + _actions["Window/DisplayScale/1.5"] = feather_tk::Action::create( "1.5", [windowWeak](bool value) { @@ -147,9 +147,9 @@ namespace toucan window->setDisplayScale(1.5F); } }); - _menus["Window/DisplayScale"]->addItem(_actions["Window/DisplayScale/1.5"]); + _menus["Window/DisplayScale"]->addAction(_actions["Window/DisplayScale/1.5"]); - _actions["Window/DisplayScale/2.0"] = std::make_shared( + _actions["Window/DisplayScale/2.0"] = feather_tk::Action::create( "2.0", [windowWeak](bool value) { @@ -158,9 +158,9 @@ namespace toucan window->setDisplayScale(2.F); } }); - _menus["Window/DisplayScale"]->addItem(_actions["Window/DisplayScale/2.0"]); + _menus["Window/DisplayScale"]->addAction(_actions["Window/DisplayScale/2.0"]); - _actions["Window/DisplayScale/2.5"] = std::make_shared( + _actions["Window/DisplayScale/2.5"] = feather_tk::Action::create( "2.5", [windowWeak](bool value) { @@ -169,9 +169,9 @@ namespace toucan window->setDisplayScale(2.5F); } }); - _menus["Window/DisplayScale"]->addItem(_actions["Window/DisplayScale/2.5"]); + _menus["Window/DisplayScale"]->addAction(_actions["Window/DisplayScale/2.5"]); - _actions["Window/DisplayScale/3.0"] = std::make_shared( + _actions["Window/DisplayScale/3.0"] = feather_tk::Action::create( "3.0", [windowWeak](bool value) { @@ -180,9 +180,9 @@ namespace toucan window->setDisplayScale(3.F); } }); - _menus["Window/DisplayScale"]->addItem(_actions["Window/DisplayScale/3.0"]); + _menus["Window/DisplayScale"]->addAction(_actions["Window/DisplayScale/3.0"]); - _actions["Window/Thumbnails"] = std::make_shared( + _actions["Window/Thumbnails"] = feather_tk::Action::create( "Thumbnails", [appWeak](bool value) { @@ -191,9 +191,9 @@ namespace toucan app->getWindowModel()->setThumbnails(value); } }); - addItem(_actions["Window/Thumbnails"]); + addAction(_actions["Window/Thumbnails"]); - _actions["Window/Tooltips"] = std::make_shared( + _actions["Window/Tooltips"] = feather_tk::Action::create( "Tooltips", [appWeak](bool value) { @@ -202,53 +202,53 @@ namespace toucan app->getWindowModel()->setTooltips(value); } }); - addItem(_actions["Window/Tooltips"]); + addAction(_actions["Window/Tooltips"]); - _fullScreenObserver = dtk::ValueObserver::create( + _fullScreenObserver = feather_tk::ValueObserver::create( window->observeFullScreen(), [this](bool value) { - setItemChecked(_actions["Window/FullScreen"], value); + setChecked(_actions["Window/FullScreen"], value); }); - _componentsObserver = dtk::MapObserver::create( + _componentsObserver = feather_tk::MapObserver::create( app->getWindowModel()->observeComponents(), [this](const std::map& value) { auto i = value.find(WindowComponent::ToolBar); - setItemChecked(_actions["Window/ToolBar"], i->second); + setChecked(_actions["Window/ToolBar"], i->second); i = value.find(WindowComponent::Tools); - setItemChecked(_actions["Window/Tools"], i->second); + setChecked(_actions["Window/Tools"], i->second); i = value.find(WindowComponent::Playback); - setItemChecked(_actions["Window/Playback"], i->second); + setChecked(_actions["Window/Playback"], i->second); i = value.find(WindowComponent::InfoBar); - setItemChecked(_actions["Window/InfoBar"], i->second); + setChecked(_actions["Window/InfoBar"], i->second); }); - _displayScaleObserver = dtk::ValueObserver::create( + _displayScaleObserver = feather_tk::ValueObserver::create( window->observeDisplayScale(), [this](float value) { - _menus["Window/DisplayScale"]->setItemChecked(_actions["Window/DisplayScale/Auto"], 0.F == value); - _menus["Window/DisplayScale"]->setItemChecked(_actions["Window/DisplayScale/1.0"], 1.F == value); - _menus["Window/DisplayScale"]->setItemChecked(_actions["Window/DisplayScale/1.5"], 1.5F == value); - _menus["Window/DisplayScale"]->setItemChecked(_actions["Window/DisplayScale/2.0"], 2.F == value); - _menus["Window/DisplayScale"]->setItemChecked(_actions["Window/DisplayScale/2.5"], 2.5F == value); - _menus["Window/DisplayScale"]->setItemChecked(_actions["Window/DisplayScale/3.0"], 3.F == value); + _menus["Window/DisplayScale"]->setChecked(_actions["Window/DisplayScale/Auto"], 0.F == value); + _menus["Window/DisplayScale"]->setChecked(_actions["Window/DisplayScale/1.0"], 1.F == value); + _menus["Window/DisplayScale"]->setChecked(_actions["Window/DisplayScale/1.5"], 1.5F == value); + _menus["Window/DisplayScale"]->setChecked(_actions["Window/DisplayScale/2.0"], 2.F == value); + _menus["Window/DisplayScale"]->setChecked(_actions["Window/DisplayScale/2.5"], 2.5F == value); + _menus["Window/DisplayScale"]->setChecked(_actions["Window/DisplayScale/3.0"], 3.F == value); }); - _thumbnailsObserver = dtk::ValueObserver::create( + _thumbnailsObserver = feather_tk::ValueObserver::create( app->getWindowModel()->observeThumbnails(), [this](bool value) { - setItemChecked(_actions["Window/Thumbnails"], value); + setChecked(_actions["Window/Thumbnails"], value); }); - _tooltipsObserver = dtk::ValueObserver::create( + _tooltipsObserver = feather_tk::ValueObserver::create( app->getWindowModel()->observeTooltips(), [this](bool value) { - setItemChecked(_actions["Window/Tooltips"], value); + setChecked(_actions["Window/Tooltips"], value); }); } @@ -256,17 +256,17 @@ namespace toucan {} std::shared_ptr WindowMenu::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& window, - const std::shared_ptr& parent) + const std::shared_ptr& parent) { auto out = std::shared_ptr(new WindowMenu); out->_init(context, app, window, parent); return out; } - const std::map >& WindowMenu::getActions() const + const std::map >& WindowMenu::getActions() const { return _actions; } diff --git a/lib/toucanView/WindowMenu.h b/lib/toucanView/WindowMenu.h index 86804ef..39853b3 100644 --- a/lib/toucanView/WindowMenu.h +++ b/lib/toucanView/WindowMenu.h @@ -5,9 +5,9 @@ #include -#include -#include -#include +#include +#include +#include namespace toucan { @@ -15,11 +15,11 @@ namespace toucan class MainWindow; //! Window menu. - class WindowMenu : public dtk::Menu + class WindowMenu : public feather_tk::Menu { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent); @@ -29,23 +29,23 @@ namespace toucan //! Create a new menu. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& parent = nullptr); //! Get the actions. - const std::map >& getActions() const; + const std::map >& getActions() const; private: - std::map > _menus; - std::map > _actions; - - std::shared_ptr > _fullScreenObserver; - std::shared_ptr > _componentsObserver; - std::shared_ptr > _displayScaleObserver; - std::shared_ptr > _thumbnailsObserver; - std::shared_ptr > _tooltipsObserver; + std::map > _menus; + std::map > _actions; + + std::shared_ptr > _fullScreenObserver; + std::shared_ptr > _componentsObserver; + std::shared_ptr > _displayScaleObserver; + std::shared_ptr > _thumbnailsObserver; + std::shared_ptr > _tooltipsObserver; }; } diff --git a/lib/toucanView/WindowModel.cpp b/lib/toucanView/WindowModel.cpp index f25fbca..dfd7e00 100644 --- a/lib/toucanView/WindowModel.cpp +++ b/lib/toucanView/WindowModel.cpp @@ -3,9 +3,9 @@ #include "WindowModel.h" -#include -#include -#include +#include +#include +#include #include @@ -14,16 +14,18 @@ namespace toucan { - DTK_ENUM_IMPL( + FEATHER_TK_ENUM_IMPL( WindowComponent, "ToolBar", "Tools", "Playback", "InfoBar"); - WindowModel::WindowModel(const std::shared_ptr& context) + WindowModel::WindowModel( + const std::shared_ptr& context, + const std::shared_ptr& settings) : + _settings(settings) { - _settings = context->getSystem(); std::map components = { { WindowComponent::ToolBar, true }, @@ -33,50 +35,57 @@ namespace toucan }; bool thumbnails = true; bool tooltips = true; - try + if (_settings) { - const auto json = std::any_cast(_settings->get("WindowModel")); - for (auto& i : components) + try { - std::stringstream ss; - ss << i.first; - auto j = json.find(ss.str()); - if (j != json.end() && j->is_boolean()) + nlohmann::json json; + _settings->get("/WindowModel", json); + for (auto& i : components) { - i.second = j->get(); + std::stringstream ss; + ss << i.first; + auto j = json.find(ss.str()); + if (j != json.end() && j->is_boolean()) + { + i.second = j->get(); + } + } + auto i = json.find("Thumbnails"); + if (i != json.end() && i->is_boolean()) + { + thumbnails = i->get(); + } + i = json.find("Tooltips"); + if (i != json.end() && i->is_boolean()) + { + tooltips = i->get(); } } - auto i = json.find("Thumbnails"); - if (i != json.end() && i->is_boolean()) - { - thumbnails = i->get(); - } - i = json.find("Tooltips"); - if (i != json.end() && i->is_boolean()) - { - tooltips = i->get(); - } + catch (const std::exception&) + {} } - catch (const std::exception&) - {} - _components = dtk::ObservableMap::create(components); - _thumbnails = dtk::ObservableValue::create(thumbnails); - _tooltips = dtk::ObservableValue::create(tooltips); + _components = feather_tk::ObservableMap::create(components); + _thumbnails = feather_tk::ObservableValue::create(thumbnails); + _tooltips = feather_tk::ObservableValue::create(tooltips); } WindowModel::~WindowModel() { - nlohmann::json json; - for (const auto i : _components->get()) + if (_settings) { - std::stringstream ss; - ss << i.first; - json[ss.str()] = i.second; + nlohmann::json json; + for (const auto i : _components->get()) + { + std::stringstream ss; + ss << i.first; + json[ss.str()] = i.second; + } + json["Thumbnails"] = _thumbnails->get(); + json["Tooltips"] = _tooltips->get(); + _settings->set("/WindowModel", json); } - json["Thumbnails"] = _thumbnails->get(); - json["Tooltips"] = _tooltips->get(); - _settings->set("WindowModel", json); } const std::map WindowModel::getComponents() const @@ -84,7 +93,7 @@ namespace toucan return _components->get(); } - std::shared_ptr > WindowModel::observeComponents() const + std::shared_ptr > WindowModel::observeComponents() const { return _components; } @@ -109,7 +118,7 @@ namespace toucan return _thumbnails->get(); } - std::shared_ptr > WindowModel::observeThumbnails() const + std::shared_ptr > WindowModel::observeThumbnails() const { return _thumbnails; } @@ -124,7 +133,7 @@ namespace toucan return _tooltips->get(); } - std::shared_ptr > WindowModel::observeTooltips() const + std::shared_ptr > WindowModel::observeTooltips() const { return _tooltips; } diff --git a/lib/toucanView/WindowModel.h b/lib/toucanView/WindowModel.h index d41c8d1..8fa2792 100644 --- a/lib/toucanView/WindowModel.h +++ b/lib/toucanView/WindowModel.h @@ -3,10 +3,10 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include namespace toucan { @@ -21,13 +21,15 @@ namespace toucan Count, First = ToolBar }; - DTK_ENUM(WindowComponent); + FEATHER_TK_ENUM(WindowComponent); //! Window model. class WindowModel : public std::enable_shared_from_this { public: - WindowModel(const std::shared_ptr&); + WindowModel( + const std::shared_ptr&, + const std::shared_ptr&); virtual ~WindowModel(); @@ -35,7 +37,7 @@ namespace toucan const std::map getComponents() const; //! Observe the window components. - std::shared_ptr > observeComponents() const; + std::shared_ptr > observeComponents() const; //! Set the window components. void setComponents(const std::map&); @@ -50,7 +52,7 @@ namespace toucan bool getThumbnails() const; //! Observe whether thumbnails are enabled. - std::shared_ptr > observeThumbnails() const; + std::shared_ptr > observeThumbnails() const; //! Set whether thumbnails are enabled. void setThumbnails(bool); @@ -59,15 +61,15 @@ namespace toucan bool getTooltips() const; //! Observe whether tooltips are enabled. - std::shared_ptr > observeTooltips() const; + std::shared_ptr > observeTooltips() const; //! Set whether tooltips are enabled. void setTooltips(bool); private: - std::shared_ptr _settings; - std::shared_ptr > _components; - std::shared_ptr > _thumbnails; - std::shared_ptr > _tooltips; + std::shared_ptr _settings; + std::shared_ptr > _components; + std::shared_ptr > _thumbnails; + std::shared_ptr > _tooltips; }; } diff --git a/lib/toucanView/WindowToolBar.cpp b/lib/toucanView/WindowToolBar.cpp index 42d53dc..7798e5b 100644 --- a/lib/toucanView/WindowToolBar.cpp +++ b/lib/toucanView/WindowToolBar.cpp @@ -11,73 +11,40 @@ namespace toucan { void WindowToolBar::_init( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& window, - const std::map >& actions, - const std::shared_ptr& parent) + const std::map >& actions, + const std::shared_ptr& parent) { - dtk::IWidget::_init(context, "toucan::WindowToolBar", parent); + feather_tk::IWidget::_init(context, "toucan::WindowToolBar", parent); - _layout = dtk::HorizontalLayout::create(context, shared_from_this()); - _layout->setSpacingRole(dtk::SizeRole::SpacingSmall); + _layout = feather_tk::HorizontalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(feather_tk::SizeRole::SpacingSmall); - auto hLayout = dtk::HorizontalLayout::create(context, _layout); - hLayout->setSpacingRole(dtk::SizeRole::SpacingTool); + auto hLayout = feather_tk::HorizontalLayout::create(context, _layout); + hLayout->setSpacingRole(feather_tk::SizeRole::SpacingTool); auto i = actions.find("Window/FullScreen"); - auto button = dtk::ToolButton::create(context, hLayout); - button->setIcon(i->second->icon); - button->setCheckable(true); - button->setTooltip(i->second->toolTip); - button->setCheckedCallback( - [i](bool value) - { - if (i->second->checkedCallback) - { - i->second->checkedCallback(value); - } - }); + auto button = feather_tk::ToolButton::create(context, i->second, hLayout); _buttons["Window/FullScreen"] = button; i = actions.find("Window/Tools"); - button = dtk::ToolButton::create(context, hLayout); - button->setIcon(i->second->icon); - button->setCheckable(true); - button->setTooltip(i->second->toolTip); - button->setCheckedCallback( - [i](bool value) - { - if (i->second->checkedCallback) - { - i->second->checkedCallback(value); - } - }); + button = feather_tk::ToolButton::create(context, i->second, hLayout); _buttons["Window/Tools"] = button; i = actions.find("Window/Playback"); - button = dtk::ToolButton::create(context, hLayout); - button->setIcon(i->second->icon); - button->setCheckable(true); - button->setTooltip(i->second->toolTip); - button->setCheckedCallback( - [i](bool value) - { - if (i->second->checkedCallback) - { - i->second->checkedCallback(value); - } - }); + button = feather_tk::ToolButton::create(context, i->second, hLayout); _buttons["Window/Playback"] = button; - _fullScreenObserver = dtk::ValueObserver::create( + _fullScreenObserver = feather_tk::ValueObserver::create( window->observeFullScreen(), [this](bool value) { _buttons["Window/FullScreen"]->setChecked(value); }); - _componentObserver = dtk::MapObserver::create( + _componentObserver = feather_tk::MapObserver::create( app->getWindowModel()->observeComponents(), [this](const std::map value) { @@ -92,24 +59,24 @@ namespace toucan {} std::shared_ptr WindowToolBar::create( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& app, const std::shared_ptr& window, - const std::map >& actions, - const std::shared_ptr& parent) + const std::map >& actions, + const std::shared_ptr& parent) { auto out = std::shared_ptr(new WindowToolBar); out->_init(context, app, window, actions, parent); return out; } - void WindowToolBar::setGeometry(const dtk::Box2I& value) + void WindowToolBar::setGeometry(const feather_tk::Box2I& value) { IWidget::setGeometry(value); _layout->setGeometry(value); } - void WindowToolBar::sizeHintEvent(const dtk::SizeHintEvent& event) + void WindowToolBar::sizeHintEvent(const feather_tk::SizeHintEvent& event) { IWidget::sizeHintEvent(event); _setSizeHint(_layout->getSizeHint()); diff --git a/lib/toucanView/WindowToolBar.h b/lib/toucanView/WindowToolBar.h index 7d3fbb5..7d7c3f2 100644 --- a/lib/toucanView/WindowToolBar.h +++ b/lib/toucanView/WindowToolBar.h @@ -5,10 +5,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include namespace toucan { @@ -17,14 +17,14 @@ namespace toucan class MainWindow; //! Window tool bar. - class WindowToolBar : public dtk::IWidget + class WindowToolBar : public feather_tk::IWidget { protected: void _init( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, - const std::map >&, + const std::map >&, const std::shared_ptr& parent); public: @@ -32,22 +32,22 @@ namespace toucan //! Create a new tool bar. static std::shared_ptr create( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, - const std::map >&, + const std::map >&, const std::shared_ptr& parent = nullptr); - void setGeometry(const dtk::Box2I&) override; - void sizeHintEvent(const dtk::SizeHintEvent&) override; + void setGeometry(const feather_tk::Box2I&) override; + void sizeHintEvent(const feather_tk::SizeHintEvent&) override; private: - std::shared_ptr _layout; - std::map > _buttons; + std::shared_ptr _layout; + std::map > _buttons; - std::shared_ptr > _frameViewObserver; - std::shared_ptr > _fullScreenObserver; - std::shared_ptr > _componentObserver; + std::shared_ptr > _frameViewObserver; + std::shared_ptr > _fullScreenObserver; + std::shared_ptr > _componentObserver; }; } diff --git a/tests/toucan-test/main.cpp b/tests/toucan-test/main.cpp index 93b73e9..7ff9439 100644 --- a/tests/toucan-test/main.cpp +++ b/tests/toucan-test/main.cpp @@ -17,10 +17,9 @@ #include #if defined(toucan_VIEW) -#include +#include #endif // toucan_VIEW -#include -#include +#include #include @@ -35,10 +34,9 @@ int main(int argc, char** argv) } const std::filesystem::path path(argv[1]); - auto context = dtk::Context::create(); - dtk::coreInit(context); + auto context = feather_tk::Context::create(); #if defined(toucan_VIEW) - dtk::uiInit(context); + feather_tk::uiInit(context); #endif // toucan_VIEW auto host = std::make_shared(context, getOpenFXPluginPaths(argv[0])); diff --git a/tests/toucanRenderTest/ImageGraphTest.cpp b/tests/toucanRenderTest/ImageGraphTest.cpp index 06acfdb..0652d58 100644 --- a/tests/toucanRenderTest/ImageGraphTest.cpp +++ b/tests/toucanRenderTest/ImageGraphTest.cpp @@ -12,7 +12,7 @@ namespace toucan { void imageGraphTest( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& host, const std::filesystem::path& path) { diff --git a/tests/toucanRenderTest/ImageGraphTest.h b/tests/toucanRenderTest/ImageGraphTest.h index ddbed3b..1f0df50 100644 --- a/tests/toucanRenderTest/ImageGraphTest.h +++ b/tests/toucanRenderTest/ImageGraphTest.h @@ -8,7 +8,7 @@ namespace toucan { void imageGraphTest( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::filesystem::path&); } diff --git a/tests/toucanViewTest/FilesModelTest.cpp b/tests/toucanViewTest/FilesModelTest.cpp index 0a4cc37..ae64781 100644 --- a/tests/toucanViewTest/FilesModelTest.cpp +++ b/tests/toucanViewTest/FilesModelTest.cpp @@ -16,61 +16,61 @@ namespace toucan { public: Test( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& host) { - model = std::make_shared(context, host); + model = std::make_shared(context, nullptr, host); - filesObserver = dtk::ListObserver >::create( + filesObserver = feather_tk::ListObserver >::create( model->observeFiles(), [this](const std::vector >& value) { files = value; }); - addObserver = dtk::ValueObserver::create( + addObserver = feather_tk::ValueObserver::create( model->observeAdd(), [this](int value) { add = value; }); - removeObserver = dtk::ValueObserver::create( + removeObserver = feather_tk::ValueObserver::create( model->observeRemove(), [this](int value) { remove = value; }); - currentObserver = dtk::ValueObserver>::create( + currentObserver = feather_tk::ValueObserver>::create( model->observeCurrent(), [this](const std::shared_ptr& value) { current = value; }); - currentIndexObserver = dtk::ValueObserver::create( + currentIndexObserver = feather_tk::ValueObserver::create( model->observeCurrentIndex(), [this](int value) { currentIndex = value; }); - bFileObserver = dtk::ValueObserver >::create( + bFileObserver = feather_tk::ValueObserver >::create( model->observeBFile(), [this](const std::shared_ptr& value) { bFile = value; }); - bIndexObserver = dtk::ValueObserver::create( + bIndexObserver = feather_tk::ValueObserver::create( model->observeBIndex(), [this](int value) { bIndex = value; }); - compareOptionsObserver = dtk::ValueObserver::create( + compareOptionsObserver = feather_tk::ValueObserver::create( model->observeCompareOptions(), [this](const CompareOptions& value) { @@ -88,19 +88,19 @@ namespace toucan int bIndex = -1; CompareOptions compareOptions; - std::shared_ptr > > filesObserver; - std::shared_ptr > addObserver; - std::shared_ptr > removeObserver; - std::shared_ptr > > currentObserver; - std::shared_ptr > currentIndexObserver; - std::shared_ptr > > bFileObserver; - std::shared_ptr > bIndexObserver; - std::shared_ptr > compareOptionsObserver; + std::shared_ptr > > filesObserver; + std::shared_ptr > addObserver; + std::shared_ptr > removeObserver; + std::shared_ptr > > currentObserver; + std::shared_ptr > currentIndexObserver; + std::shared_ptr > > bFileObserver; + std::shared_ptr > bIndexObserver; + std::shared_ptr > compareOptionsObserver; }; } void filesModelTest( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::shared_ptr& host, const std::filesystem::path& path) { diff --git a/tests/toucanViewTest/FilesModelTest.h b/tests/toucanViewTest/FilesModelTest.h index 8777529..79da0c0 100644 --- a/tests/toucanViewTest/FilesModelTest.h +++ b/tests/toucanViewTest/FilesModelTest.h @@ -5,12 +5,12 @@ #include -#include +#include namespace toucan { void filesModelTest( - const std::shared_ptr&, + const std::shared_ptr&, const std::shared_ptr&, const std::filesystem::path& path); } diff --git a/tests/toucanViewTest/PlaybackModelTest.cpp b/tests/toucanViewTest/PlaybackModelTest.cpp index d557fcc..b2ffc6e 100644 --- a/tests/toucanViewTest/PlaybackModelTest.cpp +++ b/tests/toucanViewTest/PlaybackModelTest.cpp @@ -17,32 +17,32 @@ namespace toucan class Test { public: - Test(const std::shared_ptr& context) + Test(const std::shared_ptr& context) { model = std::make_shared(context); - timeRangeObserver = dtk::ValueObserver::create( + timeRangeObserver = feather_tk::ValueObserver::create( model->observeTimeRange(), [this](const OTIO_NS::TimeRange& value) { timeRange = value; }); - currentTimeObserver = dtk::ValueObserver::create( + currentTimeObserver = feather_tk::ValueObserver::create( model->observeCurrentTime(), [this](const OTIO_NS::RationalTime& value) { currentTime = value; }); - inOutRangeObserver = dtk::ValueObserver::create( + inOutRangeObserver = feather_tk::ValueObserver::create( model->observeInOutRange(), [this](const OTIO_NS::TimeRange& value) { inOutRange = value; }); - playbackObserver = dtk::ValueObserver::create( + playbackObserver = feather_tk::ValueObserver::create( model->observePlayback(), [this](Playback value) { @@ -56,15 +56,15 @@ namespace toucan OTIO_NS::TimeRange inOutRange; Playback playback = Playback::Stop; - std::shared_ptr > timeRangeObserver; - std::shared_ptr > currentTimeObserver; - std::shared_ptr > inOutRangeObserver; - std::shared_ptr > playbackObserver; + std::shared_ptr > timeRangeObserver; + std::shared_ptr > currentTimeObserver; + std::shared_ptr > inOutRangeObserver; + std::shared_ptr > playbackObserver; }; } void playbackModelTest( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::filesystem::path& path) { std::cout << "playbackModelTest" << std::endl; diff --git a/tests/toucanViewTest/PlaybackModelTest.h b/tests/toucanViewTest/PlaybackModelTest.h index f908ee1..0b360c9 100644 --- a/tests/toucanViewTest/PlaybackModelTest.h +++ b/tests/toucanViewTest/PlaybackModelTest.h @@ -3,11 +3,11 @@ #pragma once -#include +#include namespace toucan { void playbackModelTest( - const std::shared_ptr&, + const std::shared_ptr&, const std::filesystem::path& path); } diff --git a/tests/toucanViewTest/SelectionModelTest.cpp b/tests/toucanViewTest/SelectionModelTest.cpp index cca5a33..0fcbd77 100644 --- a/tests/toucanViewTest/SelectionModelTest.cpp +++ b/tests/toucanViewTest/SelectionModelTest.cpp @@ -17,11 +17,11 @@ namespace toucan class Test { public: - Test(const std::shared_ptr& context) + Test(const std::shared_ptr& context) { model = std::make_shared(); - selectionObserver = dtk::ListObserver::create( + selectionObserver = feather_tk::ListObserver::create( model->observeSelection(), [this](const std::vector& value) { @@ -32,12 +32,12 @@ namespace toucan std::shared_ptr model; std::vector selection; - std::shared_ptr > selectionObserver; + std::shared_ptr > selectionObserver; }; } void selectionModelTest( - const std::shared_ptr& context, + const std::shared_ptr& context, const std::filesystem::path& path) { std::cout << "selectionModelTest" << std::endl; diff --git a/tests/toucanViewTest/SelectionModelTest.h b/tests/toucanViewTest/SelectionModelTest.h index f447659..fb3a998 100644 --- a/tests/toucanViewTest/SelectionModelTest.h +++ b/tests/toucanViewTest/SelectionModelTest.h @@ -3,13 +3,13 @@ #pragma once -#include +#include #include namespace toucan { void selectionModelTest( - const std::shared_ptr&, + const std::shared_ptr&, const std::filesystem::path& path); } diff --git a/tests/toucanViewTest/ViewModelTest.cpp b/tests/toucanViewTest/ViewModelTest.cpp index c31c90c..f656972 100644 --- a/tests/toucanViewTest/ViewModelTest.cpp +++ b/tests/toucanViewTest/ViewModelTest.cpp @@ -15,32 +15,32 @@ namespace toucan class Test { public: - Test(const std::shared_ptr& context) + Test(const std::shared_ptr& context) { model = std::make_shared(context); - zoomInObserver = dtk::ValueObserver::create( + zoomInObserver = feather_tk::ValueObserver::create( model->observeZoomIn(), [this](bool value) { zoomIn = value; }); - zoomOutObserver = dtk::ValueObserver::create( + zoomOutObserver = feather_tk::ValueObserver::create( model->observeZoomOut(), [this](bool value) { zoomOut = value; }); - zoomResetObserver = dtk::ValueObserver::create( + zoomResetObserver = feather_tk::ValueObserver::create( model->observeZoomReset(), [this](bool value) { zoomReset = value; }); - frameViewObserver = dtk::ValueObserver::create( + frameViewObserver = feather_tk::ValueObserver::create( model->observeFrameView(), [this](bool value) { @@ -54,14 +54,14 @@ namespace toucan bool zoomReset = false; bool frameView = false; - std::shared_ptr > zoomInObserver; - std::shared_ptr > zoomOutObserver; - std::shared_ptr > zoomResetObserver; - std::shared_ptr > frameViewObserver; + std::shared_ptr > zoomInObserver; + std::shared_ptr > zoomOutObserver; + std::shared_ptr > zoomResetObserver; + std::shared_ptr > frameViewObserver; }; } - void viewModelTest(const std::shared_ptr& context) + void viewModelTest(const std::shared_ptr& context) { std::cout << "viewModelTest" << std::endl; { diff --git a/tests/toucanViewTest/ViewModelTest.h b/tests/toucanViewTest/ViewModelTest.h index 7d98c20..26e4264 100644 --- a/tests/toucanViewTest/ViewModelTest.h +++ b/tests/toucanViewTest/ViewModelTest.h @@ -3,9 +3,9 @@ #pragma once -#include +#include namespace toucan { - void viewModelTest(const std::shared_ptr&); + void viewModelTest(const std::shared_ptr&); } diff --git a/tests/toucanViewTest/WindowModelTest.cpp b/tests/toucanViewTest/WindowModelTest.cpp index 2d33f98..6c0187b 100644 --- a/tests/toucanViewTest/WindowModelTest.cpp +++ b/tests/toucanViewTest/WindowModelTest.cpp @@ -15,18 +15,18 @@ namespace toucan class Test { public: - Test(const std::shared_ptr& context) + Test(const std::shared_ptr& context) { - model = std::make_shared(context); + model = std::make_shared(context, nullptr); - componentsObserver = dtk::MapObserver::create( + componentsObserver = feather_tk::MapObserver::create( model->observeComponents(), [this](const std::map& value) { components = value; }); - tooltipsObserver = dtk::ValueObserver::create( + tooltipsObserver = feather_tk::ValueObserver::create( model->observeTooltips(), [this](bool value) { @@ -38,12 +38,12 @@ namespace toucan std::map components; bool tooltips = false; - std::shared_ptr > componentsObserver; - std::shared_ptr > tooltipsObserver; + std::shared_ptr > componentsObserver; + std::shared_ptr > tooltipsObserver; }; } - void windowModelTest(const std::shared_ptr& context) + void windowModelTest(const std::shared_ptr& context) { std::cout << "windowModelTest" << std::endl; { diff --git a/tests/toucanViewTest/WindowModelTest.h b/tests/toucanViewTest/WindowModelTest.h index 9e601fe..709b8f6 100644 --- a/tests/toucanViewTest/WindowModelTest.h +++ b/tests/toucanViewTest/WindowModelTest.h @@ -3,9 +3,9 @@ #pragma once -#include +#include namespace toucan { - void windowModelTest(const std::shared_ptr&); + void windowModelTest(const std::shared_ptr&); }