From 24bc7b92a96a47555a93deae637242b38b502835 Mon Sep 17 00:00:00 2001 From: Robin Davies Date: Tue, 3 Oct 2023 11:54:40 -0400 Subject: [PATCH] Info dialogs 0.1 --- CMakeLists.txt | 2 +- LICENSE | 17 +- src/CMakeLists.txt | 6 +- .../AutoLilvNode.cpp | 2 +- .../AutoLilvNode.hpp | 2 +- src/generate_lvtk_plugin_info/CMakeLists.txt | 1 + .../ClassFileWriter.cpp | 4 +- .../ClassFileWriter.hpp | 2 +- .../CommandLineParser.hpp | 4 +- .../LilvPiPedalUI.cpp | 2 +- .../LilvPiPedalUI.hpp | 2 +- .../LilvPluginInfo.cpp | 2 +- .../LilvPluginInfo.hpp | 2 +- src/generate_lvtk_plugin_info/main.cpp | 2 +- src/generate_lvtk_plugin_info/ss.hpp | 2 +- src/lvtk/CMakeLists.txt | 6 +- src/lvtk/IcuString.cpp | 2 +- src/lvtk/LvtkAnimator.cpp | 2 +- src/lvtk/LvtkBindingProperty.cpp | 2 +- src/lvtk/LvtkButtonBaseElement.cpp | 2 +- src/lvtk/LvtkButtonElement.cpp | 4 +- src/lvtk/LvtkContainerElement.cpp | 26 +- src/lvtk/LvtkDamageList.cpp | 2 +- src/lvtk/LvtkDialBaseElement.cpp | 2 +- src/lvtk/LvtkDialElement.cpp | 2 +- src/lvtk/LvtkDialog.cpp | 2 +- src/lvtk/LvtkDrawingContext.cpp | 2 +- src/lvtk/LvtkDropShadowElement.cpp | 2 +- src/lvtk/LvtkDropdownElement.cpp | 2 +- src/lvtk/LvtkDropdownItemElement.cpp | 2 +- src/lvtk/LvtkEditBoxElement.cpp | 2 +- src/lvtk/LvtkElement.cpp | 32 +- src/lvtk/LvtkFlexGridElement.cpp | 12 +- src/lvtk/LvtkGroupElement.cpp | 2 +- src/lvtk/LvtkLog.cpp | 2 +- src/lvtk/LvtkMarkdownElement.cpp | 291 ++++++++++++++++ src/lvtk/LvtkMessageDialog.cpp | 6 +- src/lvtk/LvtkMotionBlurElement.cpp | 2 +- src/lvtk/LvtkNumericEditBoxElement.cpp | 2 +- src/lvtk/LvtkPangoContext.cpp | 2 +- src/lvtk/LvtkPngDialElement.cpp | 2 +- src/lvtk/LvtkPngElement.cpp | 2 +- src/lvtk/LvtkRootElement.cpp | 2 +- src/lvtk/LvtkScrollContainerElement.cpp | 68 +++- src/lvtk/LvtkSlideInOutAnimationElement.cpp | 2 +- src/lvtk/LvtkStatusTextElement.cpp | 2 +- src/lvtk/LvtkStyle.cpp | 85 ++++- src/lvtk/LvtkSvg.cpp | 2 +- src/lvtk/LvtkSvgElement.cpp | 2 +- src/lvtk/LvtkTableElement.cpp | 329 ++++++++++++++++++ src/lvtk/LvtkTheme.cpp | 12 +- src/lvtk/LvtkTypes.cpp | 2 +- src/lvtk/LvtkTypographyElement.cpp | 6 +- src/lvtk/LvtkValueElement.cpp | 2 +- src/lvtk/LvtkVerticalStackElement.cpp | 2 +- src/lvtk/LvtkVuElement.cpp | 2 +- src/lvtk/LvtkWindow.cpp | 31 +- src/lvtk/LvtkX11Window.cpp | 270 +++++++++----- src/lvtk/LvtkX11Window.hpp | 7 +- src/lvtk/Utf8Utils.cpp | 2 +- src/lvtk/Utf8Utils.hpp | 2 +- src/lvtk/cleanup.hpp | 2 +- src/lvtk/include/lvtk/IcuString.hpp | 2 +- src/lvtk/include/lvtk/Lvtk.hpp | 2 +- src/lvtk/include/lvtk/LvtkAnimator.hpp | 2 +- src/lvtk/include/lvtk/LvtkBindingProperty.hpp | 2 +- .../include/lvtk/LvtkButtonBaseElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkButtonElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkCieColors.hpp | 2 +- .../include/lvtk/LvtkContainerElement.hpp | 7 +- src/lvtk/include/lvtk/LvtkDamageList.hpp | 2 +- src/lvtk/include/lvtk/LvtkDbVuElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkDialBaseElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkDialElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkDialog.hpp | 2 +- src/lvtk/include/lvtk/LvtkDrawingContext.hpp | 2 +- .../include/lvtk/LvtkDropShadowElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkDropdownElement.hpp | 2 +- .../include/lvtk/LvtkDropdownItemElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkEditBoxElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkElement.hpp | 9 +- src/lvtk/include/lvtk/LvtkFlexGridElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkGroupElement.hpp | 2 +- .../lvtk/LvtkHorizontalStackElement.hpp | 2 +- .../lvtk/LvtkIndefiniteProgressElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkLampElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkLog.hpp | 2 +- src/lvtk/include/lvtk/LvtkMarkdownElement.hpp | 63 ++++ src/lvtk/include/lvtk/LvtkMessageDialog.hpp | 2 +- .../include/lvtk/LvtkMotionBlurElement.hpp | 2 +- .../lvtk/LvtkNumericEditBoxElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkObject.hpp | 2 +- .../include/lvtk/LvtkOnOffSwitchElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkPangoContext.hpp | 2 +- src/lvtk/include/lvtk/LvtkPngDialElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkPngElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkPngStripElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkRootElement.hpp | 2 +- .../include/lvtk/LvtkScrollBarElement.hpp | 2 +- .../lvtk/LvtkScrollContainerElement.hpp | 4 +- .../lvtk/LvtkSlideInOutAnimationElement.hpp | 2 +- .../include/lvtk/LvtkStatusTextElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkStyle.hpp | 29 +- src/lvtk/include/lvtk/LvtkSvg.hpp | 2 +- src/lvtk/include/lvtk/LvtkSvgElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkSwitchElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkTableElement.hpp | 72 ++++ src/lvtk/include/lvtk/LvtkTheme.hpp | 2 +- src/lvtk/include/lvtk/LvtkTypes.hpp | 35 +- .../include/lvtk/LvtkTypographyElement.hpp | 5 +- src/lvtk/include/lvtk/LvtkUserData.hpp | 2 +- src/lvtk/include/lvtk/LvtkValueElement.hpp | 2 +- .../include/lvtk/LvtkVerticalStackElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkVuElement.hpp | 2 +- src/lvtk/include/lvtk/LvtkWindow.hpp | 5 +- src/lvtk/keysym_names.cpp | 2 +- src/lvtk/keysym_names.hpp | 2 +- src/lvtk/ss.hpp | 2 +- src/lvtk_ui/CMakeLists.txt | 11 +- src/lvtk_ui/GlobMatcher.cpp | 2 +- src/lvtk_ui/Lv2FileDialog.cpp | 18 +- src/lvtk_ui/Lv2FrequencyPlotElement.cpp | 37 +- src/lvtk_ui/Lv2PluginInfo.cpp | 2 +- src/lvtk_ui/Lv2PluginType.cpp | 2 +- src/lvtk_ui/Lv2PortView.cpp | 2 +- src/lvtk_ui/Lv2PortViewController.cpp | 2 +- src/lvtk_ui/Lv2PortViewFactory.cpp | 4 +- src/lvtk_ui/Lv2UI.cpp | 5 +- src/lvtk_ui/Lv2UI_glue.cpp | 4 +- src/lvtk_ui/Lv2Units.cpp | 2 +- src/lvtk_ui/MimeTypes.cpp | 6 +- src/lvtk_ui/PiPedalUI.cpp | 8 +- src/lvtk_ui/include/lvtk_ui/GlobMatcher.hpp | 2 +- .../include/lvtk_ui/Lv2ControlConstants.hpp | 2 +- src/lvtk_ui/include/lvtk_ui/Lv2Exception.hpp | 2 +- src/lvtk_ui/include/lvtk_ui/Lv2FileDialog.hpp | 2 +- .../lvtk_ui/Lv2FrequencyPlotElement.hpp | 7 +- src/lvtk_ui/include/lvtk_ui/Lv2PluginInfo.hpp | 2 +- src/lvtk_ui/include/lvtk_ui/Lv2PluginType.hpp | 2 +- src/lvtk_ui/include/lvtk_ui/Lv2PortView.hpp | 2 +- .../include/lvtk_ui/Lv2PortViewController.hpp | 2 +- .../include/lvtk_ui/Lv2PortViewFactory.hpp | 2 +- src/lvtk_ui/include/lvtk_ui/Lv2UI.hpp | 2 +- .../include/lvtk_ui/Lv2UI_NativeCallbacks.hpp | 2 +- src/lvtk_ui/include/lvtk_ui/Lv2Units.hpp | 4 +- src/lvtk_ui/include/lvtk_ui/MimeTypes.hpp | 2 +- src/lvtk_ui/include/lvtk_ui/PiPedalUI.hpp | 6 +- src/lvtk_ui/ss.hpp | 2 +- src/test/BindingTest.cpp | 2 +- src/test/ButtonTestPage.cpp | 14 +- src/test/ButtonTestPage.hpp | 2 +- src/test/CMakeLists.txt | 4 + src/test/CapitalizationTest.cpp | 2 +- src/test/ColorTest.cpp | 2 +- src/test/DamageListTest.cpp | 2 +- src/test/DialTestPage.cpp | 2 +- src/test/DialTestPage.hpp | 2 +- src/test/DropShadowTestPage.cpp | 6 +- src/test/DropShadowTestPage.hpp | 2 +- src/test/DropdownTestPage.cpp | 2 +- src/test/DropdownTestPage.hpp | 2 +- src/test/EditBoxTestPage.cpp | 2 +- src/test/EditBoxTestPage.hpp | 2 +- src/test/FlexGridTestPage.cpp | 10 +- src/test/FlexGridTestPage.hpp | 2 +- src/test/JsonTest.cpp | 2 +- src/test/Lv2ControlTestPage.cpp | 4 +- src/test/Lv2ControlTestPage.hpp | 2 +- src/test/Lv2UiTestPage.cpp | 2 +- src/test/Lv2UiTestPage.hpp | 2 +- src/test/LvtkMinimumMain.cpp | 2 +- src/test/LvtkTestMain.cpp | 5 +- src/test/MotionBlurTestPage.cpp | 6 +- src/test/MotionBlurTestPage.hpp | 2 +- src/test/PaletteTestPage.cpp | 4 +- src/test/PaletteTestPage.hpp | 2 +- src/test/PngTestPage.cpp | 2 +- src/test/PngTestPage.hpp | 2 +- src/test/ScrollBarTestPage.cpp | 8 +- src/test/ScrollBarTestPage.hpp | 2 +- src/test/StandardDialogTestPage.cpp | 2 +- src/test/StandardDialogTestPage.hpp | 2 +- src/test/SvgTestPage.cpp | 2 +- src/test/SvgTestPage.hpp | 2 +- src/test/SyntaxTest.cpp | 2 +- src/test/TableTestPage.cpp | 301 ++++++++++++++++ src/test/TableTestPage.hpp | 39 +++ src/test/TestPage.hpp | 2 +- src/test/TypographyTestPage.cpp | 2 +- src/test/TypographyTestPage.hpp | 2 +- src/test/VerticalStackTest.cpp | 2 +- src/test/VerticalStackTest.hpp | 2 +- src/test/ss.hpp | 2 +- src/test_plugin/CMakeLists.txt | 6 +- src/test_plugin/Lv2Plugin.cpp | 38 +- src/test_plugin/Lv2Plugin.hpp | 2 +- src/test_plugin/SamplePlugin.cpp | 2 +- src/test_plugin/SamplePlugin.hpp | 2 +- src/test_plugin/SamplePluginUi.cpp | 4 +- 199 files changed, 1931 insertions(+), 364 deletions(-) create mode 100644 src/lvtk/LvtkMarkdownElement.cpp create mode 100644 src/lvtk/LvtkTableElement.cpp create mode 100644 src/lvtk/include/lvtk/LvtkMarkdownElement.hpp create mode 100644 src/lvtk/include/lvtk/LvtkTableElement.hpp create mode 100644 src/test/TableTestPage.cpp create mode 100644 src/test/TableTestPage.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index eb7b580..7cf9125 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ add_subdirectory ("src") export(TARGETS lvtk lvtk_ui NAMESPACE Lvtk FILE FindLvtk.cmake) # set(CPACK_GENERATOR "DEB") -# set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Robin Davies ") # required +# set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Robin E. R. Davies ") # required # set(CPACK_PACKAGE_VENDOR "Robin Davies") # set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/debian/package_description.txt") # set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "TooB LV2 Guitar Effects Pedals") diff --git a/LICENSE b/LICENSE index c9973e1..cf52106 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2023 Robin Davies +Copyright (c) 2023 Robin E. R. Davies Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -16,3 +16,18 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +=== + +Third-party licenses: + +This project includes files, and uses dependencies that are +licensed under a variety of 3rd-party Open Source licenses (none of them GPL). + +A complete list of machine-generated 3rd-party licenses can be found in the files debian/copyrights-raw and debian/copyright-fixups. + +As part of the build process, the ToobAmp build generates a +cleaner and more legible set of license notices that can be found in the file build/src/ToobAmp.lv2/LICENSE.md. This file +can also be found at /usr/lib/lv2/ToobAmp.lv2/LICENSE.md +after ToobAmp is installed. + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4a4d311..f19f80d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,9 +51,9 @@ endif() -message(STATUS "CMAKE_DEB_HOST_ARCH: ${CMAKE_DEB_HOST_ARCH}") -message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") -message(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") +message(STATUS "lvtk: CMAKE_DEB_HOST_ARCH: ${CMAKE_DEB_HOST_ARCH}") +message(STATUS "lvtk: CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") +message(STATUS "lvtk: CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") add_subdirectory(generate_lvtk_plugin_info) add_subdirectory(lvtk) diff --git a/src/generate_lvtk_plugin_info/AutoLilvNode.cpp b/src/generate_lvtk_plugin_info/AutoLilvNode.cpp index a96a79f..b9861de 100644 --- a/src/generate_lvtk_plugin_info/AutoLilvNode.cpp +++ b/src/generate_lvtk_plugin_info/AutoLilvNode.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/generate_lvtk_plugin_info/AutoLilvNode.hpp b/src/generate_lvtk_plugin_info/AutoLilvNode.hpp index 71b6566..02cb399 100644 --- a/src/generate_lvtk_plugin_info/AutoLilvNode.hpp +++ b/src/generate_lvtk_plugin_info/AutoLilvNode.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/generate_lvtk_plugin_info/CMakeLists.txt b/src/generate_lvtk_plugin_info/CMakeLists.txt index 103ab8c..ad68adc 100644 --- a/src/generate_lvtk_plugin_info/CMakeLists.txt +++ b/src/generate_lvtk_plugin_info/CMakeLists.txt @@ -15,6 +15,7 @@ endif() add_executable(generate_lvtk_plugin_info + $ $ LilvPiPedalUI.cpp LilvPiPedalUI.hpp AutoLilvNode.cpp diff --git a/src/generate_lvtk_plugin_info/ClassFileWriter.cpp b/src/generate_lvtk_plugin_info/ClassFileWriter.cpp index c1fb655..a36992f 100644 --- a/src/generate_lvtk_plugin_info/ClassFileWriter.cpp +++ b/src/generate_lvtk_plugin_info/ClassFileWriter.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -255,6 +255,8 @@ void ClassFileWriter::Write(const std::shared_ptr pluginInfo) s << Tab() << "using namespace lvtk::ui;" << endl; s << endl; + WRITE_PROPERTY(pluginInfo, uri) + WRITE_PROPERTY(pluginInfo, name) WRITE_PROPERTY(pluginInfo, brand) WRITE_PROPERTY(pluginInfo, label) diff --git a/src/generate_lvtk_plugin_info/ClassFileWriter.hpp b/src/generate_lvtk_plugin_info/ClassFileWriter.hpp index 52b538c..6705402 100644 --- a/src/generate_lvtk_plugin_info/ClassFileWriter.hpp +++ b/src/generate_lvtk_plugin_info/ClassFileWriter.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/generate_lvtk_plugin_info/CommandLineParser.hpp b/src/generate_lvtk_plugin_info/CommandLineParser.hpp index fb08724..15ae9fa 100644 --- a/src/generate_lvtk_plugin_info/CommandLineParser.hpp +++ b/src/generate_lvtk_plugin_info/CommandLineParser.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -19,7 +19,7 @@ // MIT License // -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/src/generate_lvtk_plugin_info/LilvPiPedalUI.cpp b/src/generate_lvtk_plugin_info/LilvPiPedalUI.cpp index dadedb4..5528fc6 100644 --- a/src/generate_lvtk_plugin_info/LilvPiPedalUI.cpp +++ b/src/generate_lvtk_plugin_info/LilvPiPedalUI.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/generate_lvtk_plugin_info/LilvPiPedalUI.hpp b/src/generate_lvtk_plugin_info/LilvPiPedalUI.hpp index c081b8b..2f7540b 100644 --- a/src/generate_lvtk_plugin_info/LilvPiPedalUI.hpp +++ b/src/generate_lvtk_plugin_info/LilvPiPedalUI.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/generate_lvtk_plugin_info/LilvPluginInfo.cpp b/src/generate_lvtk_plugin_info/LilvPluginInfo.cpp index 6484f59..ce19272 100644 --- a/src/generate_lvtk_plugin_info/LilvPluginInfo.cpp +++ b/src/generate_lvtk_plugin_info/LilvPluginInfo.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/generate_lvtk_plugin_info/LilvPluginInfo.hpp b/src/generate_lvtk_plugin_info/LilvPluginInfo.hpp index 2323cc9..2045a57 100644 --- a/src/generate_lvtk_plugin_info/LilvPluginInfo.hpp +++ b/src/generate_lvtk_plugin_info/LilvPluginInfo.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/generate_lvtk_plugin_info/main.cpp b/src/generate_lvtk_plugin_info/main.cpp index 11d4ee6..f3b1498 100644 --- a/src/generate_lvtk_plugin_info/main.cpp +++ b/src/generate_lvtk_plugin_info/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/generate_lvtk_plugin_info/ss.hpp b/src/generate_lvtk_plugin_info/ss.hpp index 7436111..65a920f 100644 --- a/src/generate_lvtk_plugin_info/ss.hpp +++ b/src/generate_lvtk_plugin_info/ss.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/CMakeLists.txt b/src/lvtk/CMakeLists.txt index d63c7d7..67c5fd9 100644 --- a/src/lvtk/CMakeLists.txt +++ b/src/lvtk/CMakeLists.txt @@ -56,7 +56,7 @@ if (0) endforeach() endif() -add_library(lvtk STATIC +add_library(lvtk OBJECT ./include/lvtk/LvtkObject.hpp ./include/lvtk/IcuString.hpp ./include/lvtk/JsonVariant.hpp @@ -107,6 +107,10 @@ add_library(lvtk STATIC ./include/lvtk/LvtkSlideInOutAnimationElement.hpp ./include/lvtk/LvtkCieColors.hpp ./include/lvtk/LvtkGroupElement.hpp + ./include/lvtk/LvtkTableElement.hpp + ./include/lvtk/LvtkMarkdownElement.hpp + ./LvtkMarkdownElement.cpp + ./LvtkTableElement.cpp ./LvtkGroupElement.cpp ./LvtkCieColors.cpp ./LvtkSlideInOutAnimationElement.cpp diff --git a/src/lvtk/IcuString.cpp b/src/lvtk/IcuString.cpp index d43c3be..50eb784 100644 --- a/src/lvtk/IcuString.cpp +++ b/src/lvtk/IcuString.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkAnimator.cpp b/src/lvtk/LvtkAnimator.cpp index f845f0e..656b048 100644 --- a/src/lvtk/LvtkAnimator.cpp +++ b/src/lvtk/LvtkAnimator.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkBindingProperty.cpp b/src/lvtk/LvtkBindingProperty.cpp index 4334b13..d1787ee 100644 --- a/src/lvtk/LvtkBindingProperty.cpp +++ b/src/lvtk/LvtkBindingProperty.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkButtonBaseElement.cpp b/src/lvtk/LvtkButtonBaseElement.cpp index 7bc8866..ee82dc8 100644 --- a/src/lvtk/LvtkButtonBaseElement.cpp +++ b/src/lvtk/LvtkButtonBaseElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkButtonElement.cpp b/src/lvtk/LvtkButtonElement.cpp index db62ce0..5c1100c 100644 --- a/src/lvtk/LvtkButtonElement.cpp +++ b/src/lvtk/LvtkButtonElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -122,7 +122,7 @@ void LvtkButtonElement::RebuildChildren() .FlexAlignItems(LvtkAlignment::Center) .FlexJustification(LvtkFlexJustification::Start) .HorizontalAlignment(LvtkAlignment::Start) - .FlexColumnGap(8) + .ColumnGap(8) ; typography->Style() .TextAlign(LvtkTextAlign::Start) diff --git a/src/lvtk/LvtkContainerElement.cpp b/src/lvtk/LvtkContainerElement.cpp index edd7ca8..6cbfb9e 100644 --- a/src/lvtk/LvtkContainerElement.cpp +++ b/src/lvtk/LvtkContainerElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -126,6 +126,30 @@ void LvtkContainerElement::FinalizeLayout(const LvtkRectangle &layoutClipBounds, } } +bool LvtkContainerElement::FireScrollWheel(LvtkScrollWheelEventArgs &event) +{ + if (Style().Visibility() == LvtkVisibility::Visible) + { + + if (this->screenBorderBounds.Contains(event.screenPoint)) + { + for (int64_t i = children.size() - 1; i >= 0; --i) + { + auto child = children[i]; + if (child->screenBorderBounds.Contains(event.screenPoint)) + { + if (child->FireScrollWheel(event)) + return true; + } + } + } + return super::FireScrollWheel(event); + } + return false; + +} + + bool LvtkContainerElement::FireMouseDown(LvtkMouseEventArgs &event) { if (Style().Visibility() == LvtkVisibility::Visible) diff --git a/src/lvtk/LvtkDamageList.cpp b/src/lvtk/LvtkDamageList.cpp index bd70417..bea38ca 100644 --- a/src/lvtk/LvtkDamageList.cpp +++ b/src/lvtk/LvtkDamageList.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkDialBaseElement.cpp b/src/lvtk/LvtkDialBaseElement.cpp index 252905d..1f87805 100644 --- a/src/lvtk/LvtkDialBaseElement.cpp +++ b/src/lvtk/LvtkDialBaseElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkDialElement.cpp b/src/lvtk/LvtkDialElement.cpp index e22a0dd..283b07d 100644 --- a/src/lvtk/LvtkDialElement.cpp +++ b/src/lvtk/LvtkDialElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkDialog.cpp b/src/lvtk/LvtkDialog.cpp index ef0c23a..6f7bbbd 100644 --- a/src/lvtk/LvtkDialog.cpp +++ b/src/lvtk/LvtkDialog.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkDrawingContext.cpp b/src/lvtk/LvtkDrawingContext.cpp index 71a45b4..194fc35 100644 --- a/src/lvtk/LvtkDrawingContext.cpp +++ b/src/lvtk/LvtkDrawingContext.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkDropShadowElement.cpp b/src/lvtk/LvtkDropShadowElement.cpp index 2dc2312..1c39434 100644 --- a/src/lvtk/LvtkDropShadowElement.cpp +++ b/src/lvtk/LvtkDropShadowElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkDropdownElement.cpp b/src/lvtk/LvtkDropdownElement.cpp index 94607a7..ab84f62 100644 --- a/src/lvtk/LvtkDropdownElement.cpp +++ b/src/lvtk/LvtkDropdownElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkDropdownItemElement.cpp b/src/lvtk/LvtkDropdownItemElement.cpp index ac89698..b7dd1a1 100644 --- a/src/lvtk/LvtkDropdownItemElement.cpp +++ b/src/lvtk/LvtkDropdownItemElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkEditBoxElement.cpp b/src/lvtk/LvtkEditBoxElement.cpp index b0718c2..8b81110 100644 --- a/src/lvtk/LvtkEditBoxElement.cpp +++ b/src/lvtk/LvtkEditBoxElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkElement.cpp b/src/lvtk/LvtkElement.cpp index 8dfd2e0..a2c6224 100644 --- a/src/lvtk/LvtkElement.cpp +++ b/src/lvtk/LvtkElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -697,6 +697,16 @@ bool LvtkElement::OnMouseDown(LvtkMouseEventArgs &event) } return false; } +bool LvtkElement::OnScrollWheel(LvtkScrollWheelEventArgs &event) +{ + if (ScrollWheel.Fire(event)) + { + return true; + } + return false; +} + + bool LvtkElement::OnMouseUp(LvtkMouseEventArgs &event) { if (MouseUp.Fire(event)) @@ -775,6 +785,23 @@ bool LvtkElement::FireKeyDown(const LvtkKeyboardEventArgs &event) return false; } +bool LvtkElement::FireScrollWheel(LvtkScrollWheelEventArgs &event) +{ + if (Style().Visibility() == LvtkVisibility::Visible) + { + if (this->screenBorderBounds.Contains(event.screenPoint)) + { + event.point = event.screenPoint - LvtkPoint(this->screenClientBounds.Left(), this->screenClientBounds.Top()); + if (OnScrollWheel(event)) + { + return true; + } + } + } + return false; +} + + bool LvtkElement::FireMouseDown(LvtkMouseEventArgs &event) { if (Style().Visibility() == LvtkVisibility::Visible) @@ -1217,4 +1244,5 @@ void LvtkElement::OnLayoutComplete() bool LvtkElement::LayoutValid() const { return this->layoutValid; -} \ No newline at end of file +} + diff --git a/src/lvtk/LvtkFlexGridElement.cpp b/src/lvtk/LvtkFlexGridElement.cpp index 528d441..c7e3f82 100644 --- a/src/lvtk/LvtkFlexGridElement.cpp +++ b/src/lvtk/LvtkFlexGridElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -25,8 +25,8 @@ using namespace lvtk; LvtkSize LvtkFlexGridElement::MeasureClient(LvtkSize constraint, LvtkSize available, LvtkDrawingContext &context) { this->clipChildren = false; - flexRowGap = Style().FlexRowGap().PixelValue(); - flexColumnGap = Style().FlexColumnGap().PixelValue(); + flexRowGap = Style().RowGap().PixelValue(); + flexColumnGap = Style().ColumnGap().PixelValue(); childInfos.resize(0); flows.resize(0); @@ -286,7 +286,7 @@ LvtkSize LvtkFlexGridElement::MeasureClient(LvtkSize constraint, LvtkSize availa double rowGap = currentFlow.childStart == currentFlow.childEnd ? 0: this->flexRowGap; - if (element->Style().VerticalAlignment() == LvtkAlignment::Stretch && constraint.Width() != 0) // only stretch if we are stretchy. + if (element->Style().HorizontalAlignment() == LvtkAlignment::Stretch && constraint.Width() != 0) // only stretch if we are stretchy. { ChildInfo childInfo; childInfo.nFlow = nFlow; @@ -481,8 +481,8 @@ LvtkSize LvtkFlexGridElement::Arrange(LvtkSize available, LvtkDrawingContext &co LvtkSize paddingSize = this->removeThickness(borderSize,style.BorderWidth()); LvtkSize clientSize = this->removeThickness(paddingSize,style.Padding()); - double columnGap = Style().FlexColumnGap().PixelValue(); - double rowGap = Style().FlexRowGap().PixelValue(); + double columnGap = Style().ColumnGap().PixelValue(); + double rowGap = Style().RowGap().PixelValue(); if (style.FlexDirection() == LvtkFlexDirection::Row) { double top = 0; diff --git a/src/lvtk/LvtkGroupElement.cpp b/src/lvtk/LvtkGroupElement.cpp index a77ee05..fb0f7ce 100644 --- a/src/lvtk/LvtkGroupElement.cpp +++ b/src/lvtk/LvtkGroupElement.cpp @@ -15,7 +15,7 @@ LvtkGroupElement::LvtkGroupElement() flexGrid->Style() .HorizontalAlignment(LvtkAlignment::Start) .FlexWrap(LvtkFlexWrap::Wrap) - .FlexRowGap(16); + .RowGap(16); super::AddChild(flexGrid); diff --git a/src/lvtk/LvtkLog.cpp b/src/lvtk/LvtkLog.cpp index 8a8c6ad..29a8f2c 100644 --- a/src/lvtk/LvtkLog.cpp +++ b/src/lvtk/LvtkLog.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkMarkdownElement.cpp b/src/lvtk/LvtkMarkdownElement.cpp new file mode 100644 index 0000000..efa664c --- /dev/null +++ b/src/lvtk/LvtkMarkdownElement.cpp @@ -0,0 +1,291 @@ +/* +Copyright (c) 2023 Robin E. R. Davies + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "lvtk/LvtkMarkdownElement.hpp" +#include "lvtk/LvtkFlexGridElement.hpp" +#include +#include + +using namespace lvtk; + +namespace lvtk::implementation +{ + class MarkdownTypographyElement : public LvtkTypographyElement + { + public: + using self = MarkdownTypographyElement; + using super = LvtkTypographyElement; + using ptr = std::shared_ptr; + static ptr Create() { return std::make_shared(); } + + protected: + virtual void OnMount() override + { + super::OnMount(); + Style().BorderColor(Theme().dividerColor); + } + }; + class MarkdownRuleElement : public LvtkElement + { + public: + using self = MarkdownRuleElement; + using super = LvtkElement; + using ptr = std::shared_ptr; + static ptr Create() { return std::make_shared(); } + + MarkdownRuleElement() + { + Style() + .Height(1) + .HorizontalAlignment(LvtkAlignment::Stretch); + } + + protected: + virtual void OnMount() override + { + super::OnMount(); + Style().Background(Theme().dividerColor); + } + }; +} + +using namespace lvtk::implementation; + +LvtkMarkdownElement::LvtkMarkdownElement() +{ + Style().HorizontalAlignment(LvtkAlignment::Stretch); +} +void LvtkMarkdownElement::SetMarkdown(const std::string &text) +{ + std::stringstream s(text); + SetMarkdown(s); +} +void LvtkMarkdownElement::SetMarkdown(std::istream &s) +{ + std::string line; + while (s) + { + std::getline(s, line); + AddMarkdownLine(line); + } + FlushMarkdown(); +} +void LvtkMarkdownElement::FlushMarkdown() +{ + if (lineBuffer.length() == 0) + return; + + auto element = MarkdownTypographyElement::Create(); + element->Variant(textVariant) + .Text(lineBuffer); + element->Style() + .SingleLine(false); + lineBuffer.resize(0); + + if (lineBreak) + { + lineBreak = false; + element->Style() + .MarginBottom(0) + .PaddingBottom(8); + } + if (hangingText.length() != 0) + { + constexpr double HANGING_INDENT_WIDTH = 32; + auto hangingElement = LvtkTypographyElement::Create(); + + hangingElement->Variant(textVariant).Text(hangingText); + hangingElement->Style() + .SingleLine(false) + .Width(HANGING_INDENT_WIDTH); + auto grid = LvtkFlexGridElement::Create(); + grid->Style() + .FlexDirection(LvtkFlexDirection::Row) + .FlexWrap(LvtkFlexWrap::NoWrap) + .FlexAlignItems(LvtkAlignment::Start) + .HorizontalAlignment(LvtkAlignment::Stretch) + .MarginLeft(leftMargin) + .MarginBottom(8); + grid->AddChild(hangingElement); + grid->AddChild(element); + this->leftMargin += HANGING_INDENT_WIDTH; + } + else + { + element->Style().MarginLeft(leftMargin).MarginBottom(8); + AddChild(element); + } +} + +static bool StripHangingIndent(const std::string &line, std::string &hangingText, std::string &lineOut, size_t &hangingIndentSpaces) +{ + hangingIndentSpaces = 0; + size_t hangingIndentPosition = std::string::npos; + if (line.starts_with("- ")) + { + hangingIndentPosition = 1; + } + else + { + size_t i = 0; + while (i < line.size() && ((line[i] >= '0' && line[i] <= '9') || line[i] == '.')) + { + ++i; + } + if (i != 0) + { + if (line[i - 1] == '.' && i < line.length() && line[i] == ' ') + { + hangingIndentPosition = i; + } + } + if (hangingIndentPosition == std::string::npos) + { + size_t i = 0; + while (i < line.size() && ((line[i] >= 'a' && line[i] <= 'z'))) + { + ++i; + } + if (i != 0) + { + if (i + 2 < line.length()) + { + if (line[i] == ')' && line[i + 1] == ' ') + { + hangingIndentPosition = i + 1; + } + else if (line[i] == '.' && line[i + 1] == ' ') + { + hangingIndentPosition = i + 1; + } + } + } + } + if (hangingIndentPosition == std::string::npos) + { + return false; + } + hangingText = std::string(line.begin(), line.end() + i); + while (i < line.size() && line[i] == ' ') + { + ++i; + } + lineOut = std::string(line.begin() + i, line.end()); + hangingIndentSpaces = i; + return true; + } + return false; +} + +void LvtkMarkdownElement::AddMarkdownLine(const std::string &text_) +{ + std::string text = text_; + if (text.length() == 0) + { + FlushMarkdown(); + return; + } + if (text == "---") + { + FlushMarkdown(); + AddChild(MarkdownRuleElement::Create()); + return; + } + if (lineBuffer.length() == 0) + { + + std::string lineOut; + size_t hangingIndentSpaces; + if (StripHangingIndent(text, this->hangingText, lineOut, hangingIndentSpaces)) + { + lineBuffer = lineOut; + hangingIndentStack.push_back({this->leftMargin, this->hangingIndentChars}); + this->hangingIndentChars = hangingIndentSpaces; + return; + } + } + else + { + + while (hangingIndentStack.size() != 0) + { + bool hasIndent = true; + for (size_t i = 0; i < hangingIndentChars; ++i) + { + if (i >= text.length() || text[i] != ' ') + { + hasIndent = false; + break; + } + } + if (hasIndent) + { + text = std::string(text.begin() + hangingIndentChars, text.end()); + break; + } + FlushMarkdown(); + } + } + size_t ws = 0; + while (ws < text.length() && text[ws] == ' ') + ++ws; + if (ws != 0) + { + text = std::string(text.begin() + ws, text.end()); + } + + if (text.ends_with(" ")) + { + std::string t = std::string(text.begin(), text.end() - 2); + lineBreak = true; + lineBuffer += t; + FlushMarkdown(); + return; + } + if (lineBuffer.length() != 0 && !lineBuffer.ends_with(' ')) + { + lineBuffer += ' '; + } + lineBuffer += text; +} + +LvtkMarkdownElement &LvtkMarkdownElement::TextVariant(LvtkTypographyVariant textVariant) +{ + this->textVariant = textVariant; + return *this; +} +LvtkTypographyVariant LvtkMarkdownElement::TextVariant() const +{ + return this->textVariant; +} + +void LvtkMarkdownElement::AddMarkdownFile(const std::filesystem::path &path) +{ + std::ifstream f; + f.open(path); + std::string line; + while (f) + { + getline(f, line); + AddMarkdownLine(line); + } + FlushMarkdown(); +} diff --git a/src/lvtk/LvtkMessageDialog.cpp b/src/lvtk/LvtkMessageDialog.cpp index 3fc6594..5262aa5 100644 --- a/src/lvtk/LvtkMessageDialog.cpp +++ b/src/lvtk/LvtkMessageDialog.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -126,9 +126,11 @@ void LvtkMessageDialog::OnSecondaryButton() Close(); } + #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#ifndef __clang__ #pragma GCC optimize("no-var-tracking") // to speed up compilation +#endif LvtkElement::ptr LvtkMessageDialog::Render() { diff --git a/src/lvtk/LvtkMotionBlurElement.cpp b/src/lvtk/LvtkMotionBlurElement.cpp index 260b8e0..f3523ce 100644 --- a/src/lvtk/LvtkMotionBlurElement.cpp +++ b/src/lvtk/LvtkMotionBlurElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkNumericEditBoxElement.cpp b/src/lvtk/LvtkNumericEditBoxElement.cpp index 8ac1939..dc8fa35 100644 --- a/src/lvtk/LvtkNumericEditBoxElement.cpp +++ b/src/lvtk/LvtkNumericEditBoxElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkPangoContext.cpp b/src/lvtk/LvtkPangoContext.cpp index 9ab3b4c..961603b 100644 --- a/src/lvtk/LvtkPangoContext.cpp +++ b/src/lvtk/LvtkPangoContext.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkPngDialElement.cpp b/src/lvtk/LvtkPngDialElement.cpp index fade7bc..153aa7b 100644 --- a/src/lvtk/LvtkPngDialElement.cpp +++ b/src/lvtk/LvtkPngDialElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkPngElement.cpp b/src/lvtk/LvtkPngElement.cpp index 7d73334..ac06f93 100644 --- a/src/lvtk/LvtkPngElement.cpp +++ b/src/lvtk/LvtkPngElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkRootElement.cpp b/src/lvtk/LvtkRootElement.cpp index 5f396a9..050cd81 100644 --- a/src/lvtk/LvtkRootElement.cpp +++ b/src/lvtk/LvtkRootElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkScrollContainerElement.cpp b/src/lvtk/LvtkScrollContainerElement.cpp index c4deafb..61a5209 100644 --- a/src/lvtk/LvtkScrollContainerElement.cpp +++ b/src/lvtk/LvtkScrollContainerElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -272,3 +272,69 @@ bool LvtkScrollContainerElement::ClipChildren() const { return true; } + +bool LvtkScrollContainerElement::OnScrollWheel(LvtkScrollWheelEventArgs &event) { + constexpr double SCROLL_AMOUNT = 24; + + switch (event.scrollDirection) + { + case LvtkScrollDirection::Left: + { + if (this->HorizontalScrollEnabled()) + { + double newValue = HorizontalScrollOffset()-SCROLL_AMOUNT; + if (newValue < 0) + { + newValue = 0; + } + HorizontalScrollOffset(newValue); + return true; + } + break; + } + case LvtkScrollDirection::Right: + { + if (this->HorizontalScrollEnabled()) + { + double newValue = HorizontalScrollOffset() +SCROLL_AMOUNT; + if (newValue > MaximumHorizontalScrollOffset()) + { + newValue = MaximumHorizontalScrollOffset(); + } + HorizontalScrollOffset(newValue); + return true; + } + break; + } + + case LvtkScrollDirection::Up: + { + if (this->VerticalScrollEnabled()) + { + double newValue = VerticalScrollOffset()-SCROLL_AMOUNT; + if (newValue < 0) + { + newValue = 0; + } + VerticalScrollOffset(newValue); + return true; + } + break; + } + case LvtkScrollDirection::Down: + if (this->VerticalScrollEnabled()) + { + double newValue = VerticalScrollOffset()+SCROLL_AMOUNT; + if (newValue > this->MaximumVerticalScrollOffset()) + { + newValue = MaximumVerticalScrollOffset(); + } + VerticalScrollOffset(newValue); + return true; + } + break; + + } + return false; +} + diff --git a/src/lvtk/LvtkSlideInOutAnimationElement.cpp b/src/lvtk/LvtkSlideInOutAnimationElement.cpp index 1c3aa6d..e08a7b7 100644 --- a/src/lvtk/LvtkSlideInOutAnimationElement.cpp +++ b/src/lvtk/LvtkSlideInOutAnimationElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkStatusTextElement.cpp b/src/lvtk/LvtkStatusTextElement.cpp index b997188..aadbedf 100644 --- a/src/lvtk/LvtkStatusTextElement.cpp +++ b/src/lvtk/LvtkStatusTextElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkStyle.cpp b/src/lvtk/LvtkStyle.cpp index b4933a1..9764f45 100644 --- a/src/lvtk/LvtkStyle.cpp +++ b/src/lvtk/LvtkStyle.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -82,6 +82,11 @@ LvtkStyle &LvtkStyle::Padding(const LvtkThicknessMeasurement &value) padding = value; return *this; } +LvtkStyle &LvtkStyle::CellPadding(const LvtkThicknessMeasurement &value) +{ + cellPadding = value; + return *this; +} LvtkStyle &LvtkStyle::BorderColor(const LvtkPattern &pattern) { @@ -205,6 +210,20 @@ LvtkThicknessMeasurement LvtkStyle::Padding() const LvtkThicknessMeasurement result; return result; } + +LvtkThicknessMeasurement LvtkStyle::CellPadding() const +{ + std::optional value = FromSelfOrClasses(&LvtkStyle::cellPadding); + if (value.has_value()) + { + LvtkThicknessMeasurement result = value.value(); + result.ResolvePercent(this->elementSize); + return result; + } + LvtkThicknessMeasurement result; + return result; +} + LvtkThicknessMeasurement LvtkStyle::BorderWidth() const { std::optional value = FromSelfOrClasses(&LvtkStyle::borderWidth); @@ -842,24 +861,24 @@ LvtkStyle &LvtkStyle::PaddingBottom(const LvtkMeasurement &value) return *this; } -LvtkStyle &LvtkStyle::FlexRowGap(const LvtkMeasurement &value) +LvtkStyle &LvtkStyle::RowGap(const LvtkMeasurement &value) { flexRowGap = value; return *this; } -LvtkMeasurement LvtkStyle::FlexRowGap() const +LvtkMeasurement LvtkStyle::RowGap() const { LvtkMeasurement result = FromSelfOrClasses(&LvtkStyle::flexRowGap); result.ResolvePercent(this->elementSize.Height()); return result; } -LvtkStyle &LvtkStyle::FlexColumnGap(const LvtkMeasurement &value) +LvtkStyle &LvtkStyle::ColumnGap(const LvtkMeasurement &value) { flexColumnGap = value; return *this; } -LvtkMeasurement LvtkStyle::FlexColumnGap() const +LvtkMeasurement LvtkStyle::ColumnGap() const { LvtkMeasurement result = FromSelfOrClasses(&LvtkStyle::flexColumnGap); result.ResolvePercent(this->elementSize.Width()); @@ -945,5 +964,61 @@ std::optional LvtkStyle::MaxWidth() const return result; } +LvtkStyle &LvtkStyle::CellPaddingLeft(const LvtkMeasurement &value) +{ + if (!cellPadding.has_value()) + { + cellPadding = LvtkThicknessMeasurement(0, 0, 0, 0); + } + cellPadding.value().Left(value); + return *this; +} +LvtkStyle &LvtkStyle::CellPaddingTop(const LvtkMeasurement &value) +{ + if (!cellPadding.has_value()) + { + cellPadding = LvtkThicknessMeasurement(0, 0, 0, 0); + } + cellPadding.value().Top(value); + return *this; +} +LvtkStyle &LvtkStyle::CellPaddingRight(const LvtkMeasurement &value) +{ + if (!cellPadding.has_value()) + { + cellPadding = LvtkThicknessMeasurement(0, 0, 0, 0); + } + cellPadding.value().Right(value); + return *this; +} + +LvtkStyle &LvtkStyle::CellPaddingStart(const LvtkMeasurement &value) +{ + if (!cellPadding.has_value()) + { + cellPadding = LvtkThicknessMeasurement(0, 0, 0, 0); + } + cellPadding.value().Left(value); + return *this; +} +LvtkStyle &LvtkStyle::CellPaddingEnd(const LvtkMeasurement &value) +{ + if (!cellPadding.has_value()) + { + cellPadding = LvtkThicknessMeasurement(0, 0, 0, 0); + } + cellPadding.value().Right(value); + return *this; +} + +LvtkStyle &LvtkStyle::CellPaddingBottom(const LvtkMeasurement &value) +{ + if (!cellPadding.has_value()) + { + cellPadding = LvtkThicknessMeasurement(0, 0, 0, 0); + } + cellPadding.value().Bottom(value); + return *this; +} diff --git a/src/lvtk/LvtkSvg.cpp b/src/lvtk/LvtkSvg.cpp index 98a0592..cba30aa 100644 --- a/src/lvtk/LvtkSvg.cpp +++ b/src/lvtk/LvtkSvg.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkSvgElement.cpp b/src/lvtk/LvtkSvgElement.cpp index a32ee35..44914a0 100644 --- a/src/lvtk/LvtkSvgElement.cpp +++ b/src/lvtk/LvtkSvgElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkTableElement.cpp b/src/lvtk/LvtkTableElement.cpp new file mode 100644 index 0000000..1487e67 --- /dev/null +++ b/src/lvtk/LvtkTableElement.cpp @@ -0,0 +1,329 @@ +// Copyright (c) 2023 Robin E. R. Davies +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#include "lvtk/LvtkTableElement.hpp" +#include "lvtk/LvtkLog.hpp" + +using namespace lvtk; + +LvtkTableElement &LvtkTableElement::AddRow(const std::vector &children) +{ + auto &c = Children(); + c.insert(c.end(), children.begin(), children.end()); + return *this; +} +LvtkTableElement &LvtkTableElement::AddRow(std::vector &&children) +{ + auto &c = Children(); + c.insert(c.end(), std::make_move_iterator(children.begin()), std::make_move_iterator(children.end())); + return *this; +} + +std::vector &LvtkTableElement::ColumnDefinitions() +{ + return columnDefinitions; +} +LvtkTableElement &LvtkTableElement::ColumnDefinitions(const std::vector &columnDefinitions) +{ + this->columnDefinitions = columnDefinitions; + return *this; +} + +LvtkTableElement &LvtkTableElement::ColumnDefinitions(std::vector &&columnDefinitions) +{ + this->columnDefinitions = std::move(columnDefinitions); + return *this; +} + +size_t LvtkTableElement::ColumnCount() const +{ + return columnDefinitions.size(); +} +LvtkTableElement &LvtkTableElement::ColumnCount(size_t columns) +{ + columnDefinitions.resize(columns); + return *this; +} + +size_t LvtkTableElement::RowCount() const +{ + if (ColumnCount() == 0) + { + return 0; + } + return ChildCount() / ColumnCount(); +} + +LvtkElement::ptr &LvtkTableElement::Child(size_t row, size_t column) +{ + return Children()[row * ColumnCount() + column]; +} + +LvtkSize LvtkTableElement::MeasureClient( + LvtkSize clientConstraint, + LvtkSize clientAvailable, + LvtkDrawingContext &context) +{ + + size_t rowCount = RowCount(); + size_t columnCount = ColumnCount(); + + auto borderThickness = Style().BorderWidth().PixelValue(); + auto cellPadding = Style().CellPadding().PixelValue(); + + LvtkSize cellExtra { cellPadding.left+cellPadding.right,cellPadding.top+cellPadding.bottom} ; + double rowGap = borderThickness.top; + double columnGap = borderThickness.left; + + this->rowHeights.resize(rowCount); + this->columnWidths.resize(columnCount); + + // pass 1: measure all auto and fixed-width columns. + double totalWeights = 0; + double fixedWidths = 0; + for (size_t c = 0; c < columnCount; ++c) + { + auto &columnDefinition = columnDefinitions[c]; + if (columnDefinition.columnAlignment == LvtkAlignment::Stretch) + { + columnWidths[c] = -1; + double weight = columnDefinition.columnWidth; + if (weight == 0) + weight = 1; + totalWeights += weight; + } + else + { + + LvtkSize childAvailable = clientAvailable; + + if (columnDefinition.columnWidth != 0) + { + LvtkSize childConstraint(columnDefinition.columnWidth- cellExtra.Width(), 0); + for (size_t r = 0; r < rowCount; ++r) + { + auto &child = Child(r, c); + child->Measure(childConstraint, childAvailable, context); + LvtkSize size = child->MeasuredSize(); + size = size + cellExtra; + if (size.Height() > rowHeights[r]) + { + rowHeights[r] = size.Height(); + } + } + fixedWidths += columnDefinition.columnWidth; + columnWidths[c] = columnDefinition.columnWidth; + } + else + { + // auto width. + LvtkSize childConstraint(0, 0); + double maxWidth = 0; + + for (size_t r = 0; r < rowCount; ++r) + { + auto &child = Child(r, c); + child->Measure(childConstraint, childAvailable, context); + auto size = child->MeasuredSize(); + size = size + cellExtra; + if (size.Width() > maxWidth) + { + maxWidth = size.Width(); + } + if (size.Height() > rowHeights[r]) + { + rowHeights[r] = size.Height(); + } + } + fixedWidths += maxWidth; + columnWidths[c] = maxWidth; + } + } + } + if (totalWeights != 0) + { + // divide out the extra space, and do measure of stretch columns. + double extra = 0; + if (clientConstraint.Width() == 0) + { + LogError("Table has stretch columns, but table width is not stretchy."); + extra = 10; + } + else + { + extra = clientConstraint.Width() - fixedWidths; + } + extra -= (columnCount-1)*(columnGap); + if (extra < 0) + extra = 0; + double dExtra = extra / totalWeights; + + for (size_t c = 0; c < columnCount; ++c) + { + auto &columnDefinition = columnDefinitions[c]; + if (columnDefinition.columnAlignment == LvtkAlignment::Stretch) + { + double columnWidth = columnDefinition.columnWidth == 0 + ? dExtra + : columnDefinition.columnWidth * dExtra; + columnWidths[c] = columnWidth; + double childWidth = columnWidth-cellExtra.Width(); + if (childWidth < 0) + { + childWidth = 0; + } + LvtkSize childConstraint(childWidth, 0); + + LvtkSize childAvailable(childWidth,clientAvailable.Height()); + for (size_t r = 0; r < rowCount; ++r) + { + auto &child = Child(r, c); + + child->Measure(childConstraint, childAvailable, context); + auto measureSize = child->MeasuredSize(); + measureSize = measureSize + cellExtra; + if (measureSize.Height() > rowHeights[r]) + { + rowHeights[r] = measureSize.Height(); + } + } + } + } + } + double width = 0, height = 0; + for (size_t c = 0; c < columnCount; ++c) + { + width += columnWidths[c]; + } + for (size_t r = 0; r < rowCount; ++r) + { + height += rowHeights[r]; + } + if (columnCount != 0) + { + width += (columnCount-1)*columnGap; + } + if (rowCount != 0) + { + height += (rowCount-1)*rowGap; + } + return LvtkSize{width, height}; +} + +LvtkSize LvtkTableElement::Arrange(LvtkSize available, LvtkDrawingContext &context) +{ + size_t rowCount = RowCount(); + size_t columnCount = ColumnCount(); + double y = 0; + + auto borderThickness = Style().BorderWidth().PixelValue(); + auto cellPadding = Style().CellPadding().PixelValue(); + + LvtkSize cellExtra { cellPadding.left+cellPadding.right,cellPadding.top+cellPadding.bottom} ; + double rowGap = borderThickness.top; + double columnGap = borderThickness.left; + + for (size_t r = 0; r < rowCount; ++r) + { + double x = 0; + for (size_t c = 0; c < columnCount; ++c) + { + auto &child = Child(r, c); + LvtkSize measuredSize = child->MeasuredSize(); + auto &columnDefinition = columnDefinitions[c]; + + LvtkSize childSize{measuredSize.Width(), measuredSize.Height()}; + child->Arrange(available, context); + double childX,childY; + switch (columnDefinition.columnAlignment) { + case LvtkAlignment::Start: + childX = x + cellPadding.left; + break; + case LvtkAlignment::End: + childX = x + columnWidths[c]-cellPadding.right-childSize.Width(); + break; + case LvtkAlignment::Center: + childX = x + cellPadding.left + (columnWidths[c]-cellExtra.Width()-childSize.Width())/2; + break; + + case LvtkAlignment::Stretch: + childX = x + cellPadding.left; + break; + default: + throw std::runtime_error("Invalid column alignment."); + } + switch (columnDefinition.rowAlignment) + { + case LvtkAlignment::Start: + childY = y + cellPadding.top; + break; + case LvtkAlignment::End: + childY = y + rowHeights[r]- cellPadding.bottom-childSize.Height(); + break; + case LvtkAlignment::Center: + childY = y + cellPadding.top + (rowHeights[r]-cellExtra.Height()-childSize.Height())/2; + break; + case LvtkAlignment::Stretch: + throw std::runtime_error("Not supported: ColumnDefintion::rowAlignment == LvktAlignment::Stretch"); + default: + throw std::runtime_error("Invalid row alignment."); + } + LvtkRectangle bounds{childX, childY, childSize.Width(), childSize.Height()}; + child->Layout(bounds); + x += columnWidths[c] + columnGap; + } + y += rowHeights[r] + rowGap; + } + return available; +} +void LvtkTableElement::OnDraw(LvtkDrawingContext &dc) +{ + // only gets called if border is non-empty. (see LvtkElement::WillDraw()) + super::OnDraw(dc); + + size_t rowCount = RowCount(); + size_t columnCount = ColumnCount(); + + dc.set_source(Style().BorderColor()); + auto borderWidth = Style().BorderWidth().PixelValue(); + auto size = ClientSize(); + + LvtkRectangle rc { 0,0,size.Width(), borderWidth.top}; + + double y = 0; + for (size_t r = 0; r < rowCount-1; ++r) + { + y += rowHeights[r]; + rc.Top(y); + dc.rectangle(rc); + dc.fill(); + y += borderWidth.top; + } + + double x = 0; + rc = LvtkRectangle(0,0,borderWidth.left,size.Height()); + for (size_t c = 0; c < columnCount-1; ++c) + { + x += columnWidths[c]; + rc.Left(x); + dc.rectangle(rc); + dc.fill(); + x += borderWidth.left; + } +} diff --git a/src/lvtk/LvtkTheme.cpp b/src/lvtk/LvtkTheme.cpp index a9a5ad5..7dc57c3 100644 --- a/src/lvtk/LvtkTheme.cpp +++ b/src/lvtk/LvtkTheme.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -170,33 +170,33 @@ void LvtkTheme::BuildStyles() .FontFamily(fontFamily) .FontWeight(LvtkFontWeight::Light) .FontSize(titleSize) - .LineSpacing(1.5) + .LineSpacing(1.2) .Color(secondaryTextColor)); headingStyle = std::make_shared( LvtkStyle() .FontFamily(fontFamily) .FontWeight(LvtkFontWeight::Bold) .FontSize(headingSize) - .LineSpacing(1.5) + .LineSpacing(1.2) .Color(secondaryTextColor)); bodyPrimaryStyle = std::make_shared( LvtkStyle() .FontFamily(fontFamily) .FontSize(bodySize) - .LineSpacing(1.5) + .LineSpacing(1.2) .Color(primaryTextColor)); bodySecondaryStyle = std::make_shared( LvtkStyle() .FontFamily(fontFamily) .FontSize(bodySize) - .LineSpacing(1.5) + .LineSpacing(1.2) .Color(secondaryTextColor)); captionStyle = std::make_shared( LvtkStyle() .FontFamily(fontFamily) .FontSize(captionSize) .TextTransform(LvtkTextTransform::Capitalize) - .LineSpacing(1.25) + .LineSpacing(1.0) .Color(secondaryTextColor)); buttonDisableStyle = std::make_shared( diff --git a/src/lvtk/LvtkTypes.cpp b/src/lvtk/LvtkTypes.cpp index 8ba2de6..d319695 100644 --- a/src/lvtk/LvtkTypes.cpp +++ b/src/lvtk/LvtkTypes.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkTypographyElement.cpp b/src/lvtk/LvtkTypographyElement.cpp index 0df4373..7d74e2c 100644 --- a/src/lvtk/LvtkTypographyElement.cpp +++ b/src/lvtk/LvtkTypographyElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -340,9 +340,9 @@ LvtkStyle::ptr LvtkTypographyElement::GetVariantStyle() } } -void LvtkTypographyElement::OnMount(LvtkWindow *window) +void LvtkTypographyElement::OnMount() { - super::OnMount(window); + super::OnMount(); RemoveClass(variantStyle); variantStyle = GetVariantStyle(); AddClass(variantStyle); diff --git a/src/lvtk/LvtkValueElement.cpp b/src/lvtk/LvtkValueElement.cpp index 66e0b4f..d09e005 100644 --- a/src/lvtk/LvtkValueElement.cpp +++ b/src/lvtk/LvtkValueElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkVerticalStackElement.cpp b/src/lvtk/LvtkVerticalStackElement.cpp index 217ae7b..390fd71 100644 --- a/src/lvtk/LvtkVerticalStackElement.cpp +++ b/src/lvtk/LvtkVerticalStackElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkVuElement.cpp b/src/lvtk/LvtkVuElement.cpp index fa41092..5ca0959 100644 --- a/src/lvtk/LvtkVuElement.cpp +++ b/src/lvtk/LvtkVuElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/LvtkWindow.cpp b/src/lvtk/LvtkWindow.cpp index 366b222..86efc06 100644 --- a/src/lvtk/LvtkWindow.cpp +++ b/src/lvtk/LvtkWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -213,6 +213,8 @@ void LvtkWindow::CreateChildWindow( const LvtkCreateWindowParameters ¶meters, LvtkElement::ptr element) { + this->rootElement->AddChild(element); + this->windowScale = parent->windowScale; this->windowParameters = parameters; this->windowParameters.settingsObject = parent->Settings(); @@ -295,6 +297,19 @@ bool LvtkWindow::PumpMessages(bool block) } } +bool LvtkWindow::OnScrollWheel(LvtkScrollWheelEventArgs &event) +{ + if (this->GetRootElement() != nullptr) + { + if (GetRootElement()->FireScrollWheel(event)) + { + return true; + } + } + return false; + +} + bool LvtkWindow::OnMouseDown(LvtkMouseEventArgs &event) { if (this->Capture() != nullptr) @@ -352,6 +367,15 @@ bool LvtkWindow::OnMouseMove(LvtkMouseEventArgs &event) return false; } + +void LvtkWindow::MouseScrollWheel(WindowHandle h, LvtkScrollDirection direction, int64_t x, int64_t y, ModifierState state) +{ + LvtkScrollWheelEventArgs event{h, direction, x / windowScale, y / windowScale, state}; + OnScrollWheel(event); + +} + + void LvtkWindow::MouseDown(WindowHandle h, uint64_t button, int64_t x, int64_t y, ModifierState state) { LvtkMouseEventArgs event{h, button, x / windowScale, y / windowScale, state}; @@ -1399,4 +1423,7 @@ WindowHandle LvtkWindow::Handle() const return nativeWindow->Handle(); } return WindowHandle(); -} \ No newline at end of file +} + + + diff --git a/src/lvtk/LvtkX11Window.cpp b/src/lvtk/LvtkX11Window.cpp index af83c92..163a907 100644 --- a/src/lvtk/LvtkX11Window.cpp +++ b/src/lvtk/LvtkX11Window.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -36,24 +36,28 @@ using namespace lvtk; static constexpr int ANIMATION_RATE = 60; static constexpr std::chrono::steady_clock::duration ANIMATION_DELAY = std::chrono::duration_cast(std::chrono::microseconds(1000000 / ANIMATION_RATE)); - #define X_INIT_ATOM(name) \ - name = XInternAtom(display,"_" #name, False); + name = XInternAtom(display, "_" #name, False) -struct LvtkX11Window::XAtoms { +struct LvtkX11Window::XAtoms +{ XAtoms(Display *display) { - X_INIT_ATOM(NET_FRAME_EXTENTS) - X_INIT_ATOM(NET_WM_STATE_MAXIMIZED_VERT) - X_INIT_ATOM(NET_WM_STATE_MAXIMIZED_HORZ) - X_INIT_ATOM(NET_WM_STATE_FOCUSED) - X_INIT_ATOM(NET_WM_STATE) + X_INIT_ATOM(NET_FRAME_EXTENTS); + X_INIT_ATOM(NET_WM_STATE_MAXIMIZED_VERT); + X_INIT_ATOM(NET_WM_STATE_MAXIMIZED_HORZ); + X_INIT_ATOM(NET_WM_STATE_FOCUSED); + X_INIT_ATOM(NET_WM_STATE); + X_INIT_ATOM(NET_ACTIVE_WINDOW); + X_INIT_ATOM(NET_RESTACK_WINDOW); } Atom NET_FRAME_EXTENTS, NET_WM_STATE_MAXIMIZED_VERT, NET_WM_STATE_MAXIMIZED_HORZ, NET_WM_STATE_FOCUSED, - NET_WM_STATE; + NET_WM_STATE, + NET_ACTIVE_WINDOW, + NET_RESTACK_WINDOW; }; template @@ -352,6 +356,12 @@ LvtkX11Window::LvtkX11Window( parentWindow, nullptr, parameters); + + if (parameters.owner) + { + parameters.owner->nativeWindow->childWindows.push_back(this); + this->parent = parameters.owner->nativeWindow; + } CreateSurface(size.Width(), size.Height()); } @@ -413,7 +423,6 @@ void LvtkX11Window::DestroyWindowAndSurface() cairoWindow = nullptr; t->OnX11WindowClosed(); } - } static ModifierState makeModifierState(unsigned int state) { @@ -446,6 +455,70 @@ static std::string ToX11Color(const LvtkColor &color) // s << "rgbi:" << color.R() << "/" << color.G() << '/' << color.B(); // return s.str(); } + +Window LvtkX11Window::GetTransientTarget(Window win) +{ + Window transientFor = 0; + + while (true) + { + auto status = XGetTransientForHint(x11Display, win, &transientFor); + if (status != 0) + { + + if (transientFor != 0) + { + return transientFor; + } + } + Window root, parent, *children = nullptr; + unsigned int num_children; + + XQueryTree(x11Display, win, &root, &parent, &children, &num_children); + XFree(children); + if (parent != 0) + { + win = parent; + } + else + { + break; + } + } + return 0; +} +static Window GetOwnerFrameWindow(Display *x11Display,Window win) +{ + Window transientFor = 0; + + while (true) + { + auto status = XGetTransientForHint(x11Display, win, &transientFor); + if (status != 0) + { + + if (transientFor != 0) + { + return win; + } + } + Window root, parent, *children = nullptr; + unsigned int num_children; + + XQueryTree(x11Display, win, &root, &parent, &children, &num_children); + XFree(children); + if (parent != 0) + { + win = parent; + } + else + { + break; + } + } + return 0; +} + void LvtkX11Window::CreateWindow( Window parentWindow, Display *display, @@ -454,7 +527,8 @@ void LvtkX11Window::CreateWindow( if (display) { x11Display = display; - } else if (parameters.owner != nullptr) + } + else if (parameters.owner != nullptr) { x11Display = parameters.owner->nativeWindow->x11Display; } @@ -480,32 +554,50 @@ void LvtkX11Window::CreateWindow( if (parameters.positioning != LvtkWindowPositioning::ChildWindow) { - if (!this->x11LogicalParentWindow && parameters.owner) + parentWindow = this->x11RootWindow; + this->x11ParentWindow = parentWindow; + + if (parameters.owner) { - this->x11LogicalParentWindow = (Window)(parameters.owner->Handle().getHandle()); + this->x11LogicalParentWindow = GetOwnerFrameWindow( + x11Display, + (Window)(parameters.owner->nativeWindow->Handle().getHandle())); + + // this->x11LogicalParentWindow = GetTransientTarget( + // (Window)(parameters.owner->nativeWindow->Handle().getHandle())); + if (!this->x11LogicalParentWindow) + { + this->x11LogicalParentWindow = this->x11RootWindow; + } + + // this->x11LogicalParentWindow = GetTransientFor(parameters.owner->nativeWindow->Handle()); + // this->x11LogicalParentWindow = (Window)(parameters.owner->Handle().getHandle()); + + parentWindow = this->x11ParentWindow = this->x11RootWindow; // this->x11LogicalParentWindow; + // parentWindow = this->x11ParentWindow = this->x11LogicalParentWindow; } // normal window path. - parentWindow = this->x11RootWindow; - this->x11ParentWindow = parentWindow; - } else { + } + else + { // plugin UI window. this->x11ParentWindow = parentWindow; if (parentWindow == 0) { // plugin UI window, test case. this->x11ParentWindow = x11RootWindow; - this->x11ParentWindow = x11RootWindow; + parentWindow = x11RootWindow; } } - + XSizeHints *sizeHints = (XSizeHints *)GenerateNormalHints(parameters); XSetWindowAttributes windowAttributes; memset(&windowAttributes, 0, sizeof(windowAttributes)); - if (parameters.windowType == LvtkWindowType::Dialog) - { - windowAttributes.do_not_propagate_mask = KeyPressMask | KeyReleaseMask | PointerMotionMask | ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; - } + // if (parameters.windowType == LvtkWindowType::Dialog) + // { + // windowAttributes.do_not_propagate_mask = KeyPressMask | KeyReleaseMask | PointerMotionMask | ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; + // } XColor color; memset(&color, 0, sizeof(color)); @@ -540,7 +632,7 @@ void LvtkX11Window::CreateWindow( DefaultVisual(x11Display, DefaultScreen(x11Display)), CWBackPixel | CWEventMask | CWDontPropagate, &windowAttributes); - + // auto event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | VisibilityChangeMask | PointerMotionMask | EnterWindowMask | // LeaveWindowMask | KeymapStateMask | // ButtonPressMask | ButtonMotionMask | ButtonReleaseMask | @@ -548,9 +640,18 @@ void LvtkX11Window::CreateWindow( // XSelectInput(x11Display, x11Window, event_mask); + // if (parameters.owner) + // { + // Window frameWindow = GetTopLevelSibling(parameters.owner->Handle()); + // XSetTransientForHint(x11Display,x11Window,frameWindow); + // } else if (x11LogicalParentWindow != parentWindow) { - XSetTransientForHint(x11Display, x11Window, x11LogicalParentWindow); + if ( + XSetTransientForHint(x11Display, x11Window, x11LogicalParentWindow) == 0) + { + logDebug(x11Window, "Failed to set WM_TRANSIENT_FOR"); + } } if (parameters.windowType == LvtkWindowType::Dialog) { @@ -566,23 +667,25 @@ void LvtkX11Window::CreateWindow( wmProtocols = XInternAtom(x11Display, "WM_PROTOCOLS", False); XSetWMProtocols(x11Display, x11Window, &wmDeleteWindow, 1); - SetStringProperty("_GTK_APPLICATION_ID",parameters.gtkApplicationId); + SetStringProperty("_GTK_APPLICATION_ID", parameters.gtkApplicationId); XClassHint *classHint = XAllocClassHint(); xClassHint = classHint; - + this->res_class = parameters.x11Windowclass; - classHint->res_class = const_cast(res_class.c_str()); + classHint->res_class = const_cast(res_class.c_str()); this->res_name = parameters.x11WindowName; - classHint->res_name = const_cast(this->res_name.c_str()); - XSetClassHint(x11Display,x11Window,classHint); + classHint->res_name = const_cast(this->res_name.c_str()); + XSetClassHint(x11Display, x11Window, classHint); // GetSynchronousFrameExtents(); } SetWindowType(parameters.windowType); WindowTitle(parameters.title); XMapWindow(x11Display, x11Window); + + XRaiseWindow(x11Display, x11Window); XClearWindow(x11Display, x11Window); this->size = parameters.size; @@ -774,12 +877,23 @@ void LvtkX11Window::ProcessEvent(XEvent &xEvent) if (window && !window->ModalDisable()) { - window->MouseDown( - WindowHandle(xEvent.xbutton.window), - xEvent.xbutton.button, - xEvent.xbutton.x, - xEvent.xbutton.y, - makeModifierState(xEvent.xbutton.state)); + if (xEvent.xbutton.button >= 4 && xEvent.xbutton.button <= 7) + { + window->MouseScrollWheel( + WindowHandle(xEvent.xbutton.window), + (LvtkScrollDirection)(xEvent.xbutton.button-4), + xEvent.xbutton.x, + xEvent.xbutton.y, + makeModifierState(xEvent.xbutton.state)); + + } else { + window->MouseDown( + WindowHandle(xEvent.xbutton.window), + xEvent.xbutton.button, + xEvent.xbutton.x, + xEvent.xbutton.y, + makeModifierState(xEvent.xbutton.state)); + } } break; } @@ -788,19 +902,21 @@ void LvtkX11Window::ProcessEvent(XEvent &xEvent) LvtkWindow::ptr window = GetLvtkWindow(xEvent.xbutton.window); if (window) { - window->MouseUp( - WindowHandle(xEvent.xbutton.window), - xEvent.xbutton.button, - xEvent.xbutton.x, - xEvent.xbutton.y, - makeModifierState(xEvent.xbutton.state)); + if (!(xEvent.xbutton.button >= 4 && xEvent.xbutton.button <= 7)) // ignore scrollwheel up events + { + window->MouseUp( + WindowHandle(xEvent.xbutton.window), + xEvent.xbutton.button, + xEvent.xbutton.x, + xEvent.xbutton.y, + makeModifierState(xEvent.xbutton.state)); + } } break; } case MotionNotify: { - LvtkWindow::ptr window = GetLvtkWindow(xEvent.xmotion.window); if (window && !window->ModalDisable()) @@ -894,20 +1010,16 @@ void LvtkX11Window::ProcessEvent(XEvent &xEvent) LvtkWindow::ptr window = child->cairoWindow; assert(window); - child->location = LvtkPoint((double)xEvent.xconfigure.x-this->frameExtents.left, (double)xEvent.xconfigure.y-this->frameExtents.top); + child->location = LvtkPoint((double)xEvent.xconfigure.x - this->frameExtents.left, (double)xEvent.xconfigure.y - this->frameExtents.top); LvtkSize size{(double)xEvent.xconfigure.width, (double)xEvent.xconfigure.height}; - - logDebug(xEvent.xconfigure.window, SS("ConfigureNotify (" - << xEvent.xconfigure.x << "," << xEvent.xconfigure.y - << "," << xEvent.xconfigure.width << "," << xEvent.xconfigure.height - << ") (" - << child->location.x << "," << child->location.y - << "," << size.Width() << "," << size.Height() << ")" - )); - - + logDebug(xEvent.xconfigure.window, SS("ConfigureNotify (" + << xEvent.xconfigure.x << "," << xEvent.xconfigure.y + << "," << xEvent.xconfigure.width << "," << xEvent.xconfigure.height + << ") (" + << child->location.x << "," << child->location.y + << "," << size.Width() << "," << size.Height() << ")")); if (child->size != size) { @@ -1067,7 +1179,7 @@ void LvtkX11Window::ProcessEvent(XEvent &xEvent) { if (xEvent.xproperty.state == PropertyNewValue) { - logDebug(e.window,SS("PropertyNotify new value: " << XGetAtomName(x11Display, e.atom))); + logDebug(e.window, SS("PropertyNotify new value: " << XGetAtomName(x11Display, e.atom))); if (e.atom == xAtoms->NET_FRAME_EXTENTS) { child->OnFrameExtentsUpdated(); @@ -1084,12 +1196,12 @@ void LvtkX11Window::ProcessEvent(XEvent &xEvent) break; } default: - logDebug(0,SS("Dropping unhandled XEevent.type = " << xEvent.type)); + logDebug(0, SS("Dropping unhandled XEevent.type = " << xEvent.type)); break; } } -static constexpr bool ENABLE_EVENT_TRACING = false; +static constexpr bool ENABLE_EVENT_TRACING = true; void LvtkX11Window::logDebug(Window x11Window, const std::string &message) { @@ -1106,11 +1218,11 @@ bool LvtkX11Window::GrabPointer() int result = XGrabPointer( this->x11Display, this->x11Window, - False,//True, // xxx False - ButtonPressMask | ButtonMotionMask | ButtonReleaseMask , + False, + ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, - None, //DefaultRootWindow(x11Display), // None, this->x11Window, + None, // DefaultRootWindow(x11Display), // None, this->x11Window, None, CurrentTime); return result == GrabSuccess; @@ -1398,6 +1510,11 @@ void LvtkX11Window::Close() { if (this->x11Window) { + auto parent = this; + while (parent->parent) + { + parent = parent->parent; + } EraseChild(x11Window); } } @@ -1427,10 +1544,6 @@ bool LvtkX11Window::EraseChild(Window x11Window) } } } - if (this->parent != nullptr) - { - return parent->EraseChild(x11Window); - } return false; } @@ -1445,7 +1558,7 @@ void LvtkX11Window::FireConfigurationChanged() x11Display, this->x11Window, x11LogicalParentWindow, 0, 0, &x, &y, &child); - location = LvtkPoint(x, y) - LvtkPoint(frameExtents.left,frameExtents.top); + location = LvtkPoint(x, y) - LvtkPoint(frameExtents.left, frameExtents.top); } else { @@ -1455,7 +1568,7 @@ void LvtkX11Window::FireConfigurationChanged() x11Display, this->x11Window, x11RootWindow, 0, 0, &x, &y, &child); - location = LvtkPoint(x, y) - LvtkPoint(frameExtents.left,frameExtents.top); + location = LvtkPoint(x, y) - LvtkPoint(frameExtents.left, frameExtents.top); } if (cairoWindow) { @@ -1527,15 +1640,15 @@ void LvtkX11Window::OnWmStateUpdated() { std::stringstream s; s << "_NET_WM_STATE:"; - for (Atom atom: atoms) + for (Atom atom : atoms) { - s << " " << XGetAtomName(x11Display,atom); + s << " " << XGetAtomName(x11Display, atom); } - logDebug(x11Window,s.str()); + logDebug(x11Window, s.str()); } - bool maximizedHorz = std::find(atoms.begin(),atoms.end(),xAtoms->NET_WM_STATE_MAXIMIZED_HORZ) != atoms.end(); - bool maximizedVert = std::find(atoms.begin(),atoms.end(),xAtoms->NET_WM_STATE_MAXIMIZED_VERT) != atoms.end(); - bool hidden = std::find(atoms.begin(),atoms.end(),xAtoms->NET_WM_STATE_MAXIMIZED_VERT) != atoms.end(); + bool maximizedHorz = std::find(atoms.begin(), atoms.end(), xAtoms->NET_WM_STATE_MAXIMIZED_HORZ) != atoms.end(); + bool maximizedVert = std::find(atoms.begin(), atoms.end(), xAtoms->NET_WM_STATE_MAXIMIZED_VERT) != atoms.end(); + bool hidden = std::find(atoms.begin(), atoms.end(), xAtoms->NET_WM_STATE_MAXIMIZED_VERT) != atoms.end(); LvtkWindowState windowState = LvtkWindowState::Normal; if (maximizedHorz && maximizedVert) @@ -1547,7 +1660,6 @@ void LvtkX11Window::OnWmStateUpdated() windowState = LvtkWindowState::Minimized; } this->windowState = windowState; - } } @@ -1585,25 +1697,23 @@ bool LvtkX11Window::waitForX11Event(std::chrono::milliseconds ms) return true; } -void LvtkX11Window::SetStringProperty(const std::string&key, const std::string&value) +void LvtkX11Window::SetStringProperty(const std::string &key, const std::string &value) { XTextProperty text; - text.value = (unsigned char*)(void*)(value.c_str()); + text.value = (unsigned char *)(void *)(value.c_str()); text.encoding = XA_STRING; text.format = 8; text.nitems = value.length(); - XSetTextProperty(x11Display,x11Window,&text,GetAtom(key.c_str())); + XSetTextProperty(x11Display, x11Window, &text, GetAtom(key.c_str())); } -std::optional GetStringProperty(const std::string&key) +std::optional GetStringProperty(const std::string &key) { throw std::runtime_error("Not implemented."); } void LvtkX11Window::Resize(int width, int height) { - XResizeWindow(x11Display,x11Window,width,height); + XResizeWindow(x11Display, x11Window, width, height); } - - diff --git a/src/lvtk/LvtkX11Window.hpp b/src/lvtk/LvtkX11Window.hpp index 2cd2cce..b89e040 100644 --- a/src/lvtk/LvtkX11Window.hpp +++ b/src/lvtk/LvtkX11Window.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -87,6 +87,7 @@ namespace lvtk void Close(); + void WindowTitle(const std::string &title); void SetWindowType(LvtkWindowType windowType); @@ -140,6 +141,7 @@ namespace lvtk void Resize(int width, int height); private: + struct XAtoms; std::unique_ptr xAtoms; @@ -173,6 +175,9 @@ namespace lvtk void RegisterControllerMessages(); private: + + Window GetTransientTarget(Window other); + using clock_t = std::chrono::steady_clock; diff --git a/src/lvtk/Utf8Utils.cpp b/src/lvtk/Utf8Utils.cpp index 430b523..3ced387 100644 --- a/src/lvtk/Utf8Utils.cpp +++ b/src/lvtk/Utf8Utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/Utf8Utils.hpp b/src/lvtk/Utf8Utils.hpp index c02b7aa..14c086f 100644 --- a/src/lvtk/Utf8Utils.hpp +++ b/src/lvtk/Utf8Utils.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/cleanup.hpp b/src/lvtk/cleanup.hpp index 23f9027..eba3a2d 100644 --- a/src/lvtk/cleanup.hpp +++ b/src/lvtk/cleanup.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/IcuString.hpp b/src/lvtk/include/lvtk/IcuString.hpp index f696065..8d915e4 100644 --- a/src/lvtk/include/lvtk/IcuString.hpp +++ b/src/lvtk/include/lvtk/IcuString.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/Lvtk.hpp b/src/lvtk/include/lvtk/Lvtk.hpp index ae44f62..f6dfd71 100644 --- a/src/lvtk/include/lvtk/Lvtk.hpp +++ b/src/lvtk/include/lvtk/Lvtk.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkAnimator.hpp b/src/lvtk/include/lvtk/LvtkAnimator.hpp index 767a7c1..af995e8 100644 --- a/src/lvtk/include/lvtk/LvtkAnimator.hpp +++ b/src/lvtk/include/lvtk/LvtkAnimator.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkBindingProperty.hpp b/src/lvtk/include/lvtk/LvtkBindingProperty.hpp index 7766d88..8aab7fc 100644 --- a/src/lvtk/include/lvtk/LvtkBindingProperty.hpp +++ b/src/lvtk/include/lvtk/LvtkBindingProperty.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkButtonBaseElement.hpp b/src/lvtk/include/lvtk/LvtkButtonBaseElement.hpp index 1db485e..770f14d 100644 --- a/src/lvtk/include/lvtk/LvtkButtonBaseElement.hpp +++ b/src/lvtk/include/lvtk/LvtkButtonBaseElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkButtonElement.hpp b/src/lvtk/include/lvtk/LvtkButtonElement.hpp index 6e735a1..9abb97c 100644 --- a/src/lvtk/include/lvtk/LvtkButtonElement.hpp +++ b/src/lvtk/include/lvtk/LvtkButtonElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkCieColors.hpp b/src/lvtk/include/lvtk/LvtkCieColors.hpp index 0ad0354..26bc69a 100644 --- a/src/lvtk/include/lvtk/LvtkCieColors.hpp +++ b/src/lvtk/include/lvtk/LvtkCieColors.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkContainerElement.hpp b/src/lvtk/include/lvtk/LvtkContainerElement.hpp index bff258a..2ca7f8b 100644 --- a/src/lvtk/include/lvtk/LvtkContainerElement.hpp +++ b/src/lvtk/include/lvtk/LvtkContainerElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -122,7 +122,10 @@ namespace lvtk { virtual void FinalizeLayout(const LvtkRectangle &layoutClipBounds,const LvtkRectangle& screenOffest, bool clippedInLayout = false) override; protected: virtual void OnLayoutComplete() override; - + + + virtual bool FireScrollWheel(LvtkScrollWheelEventArgs &event) override; + virtual bool FireMouseDown(LvtkMouseEventArgs&event) override; virtual bool FireMouseUp(LvtkMouseEventArgs&event) override; virtual void UpdateMouseOver(LvtkPoint mousePosition) override; diff --git a/src/lvtk/include/lvtk/LvtkDamageList.hpp b/src/lvtk/include/lvtk/LvtkDamageList.hpp index 08806f4..d99e0ee 100644 --- a/src/lvtk/include/lvtk/LvtkDamageList.hpp +++ b/src/lvtk/include/lvtk/LvtkDamageList.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkDbVuElement.hpp b/src/lvtk/include/lvtk/LvtkDbVuElement.hpp index 8d5876a..eaa407e 100644 --- a/src/lvtk/include/lvtk/LvtkDbVuElement.hpp +++ b/src/lvtk/include/lvtk/LvtkDbVuElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkDialBaseElement.hpp b/src/lvtk/include/lvtk/LvtkDialBaseElement.hpp index f3b67ab..e7c6be1 100644 --- a/src/lvtk/include/lvtk/LvtkDialBaseElement.hpp +++ b/src/lvtk/include/lvtk/LvtkDialBaseElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkDialElement.hpp b/src/lvtk/include/lvtk/LvtkDialElement.hpp index 0a16534..df0590b 100644 --- a/src/lvtk/include/lvtk/LvtkDialElement.hpp +++ b/src/lvtk/include/lvtk/LvtkDialElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkDialog.hpp b/src/lvtk/include/lvtk/LvtkDialog.hpp index 187f102..aad5051 100644 --- a/src/lvtk/include/lvtk/LvtkDialog.hpp +++ b/src/lvtk/include/lvtk/LvtkDialog.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkDrawingContext.hpp b/src/lvtk/include/lvtk/LvtkDrawingContext.hpp index 6187900..0dba7b3 100644 --- a/src/lvtk/include/lvtk/LvtkDrawingContext.hpp +++ b/src/lvtk/include/lvtk/LvtkDrawingContext.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkDropShadowElement.hpp b/src/lvtk/include/lvtk/LvtkDropShadowElement.hpp index b13d104..6c10703 100644 --- a/src/lvtk/include/lvtk/LvtkDropShadowElement.hpp +++ b/src/lvtk/include/lvtk/LvtkDropShadowElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkDropdownElement.hpp b/src/lvtk/include/lvtk/LvtkDropdownElement.hpp index 84bde43..113e91e 100644 --- a/src/lvtk/include/lvtk/LvtkDropdownElement.hpp +++ b/src/lvtk/include/lvtk/LvtkDropdownElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkDropdownItemElement.hpp b/src/lvtk/include/lvtk/LvtkDropdownItemElement.hpp index 0ac0dfc..858d69b 100644 --- a/src/lvtk/include/lvtk/LvtkDropdownItemElement.hpp +++ b/src/lvtk/include/lvtk/LvtkDropdownItemElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkEditBoxElement.hpp b/src/lvtk/include/lvtk/LvtkEditBoxElement.hpp index 2ea3e41..162b255 100644 --- a/src/lvtk/include/lvtk/LvtkEditBoxElement.hpp +++ b/src/lvtk/include/lvtk/LvtkEditBoxElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkElement.hpp b/src/lvtk/include/lvtk/LvtkElement.hpp index 2959ce1..02a62f9 100644 --- a/src/lvtk/include/lvtk/LvtkElement.hpp +++ b/src/lvtk/include/lvtk/LvtkElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -112,6 +112,10 @@ namespace lvtk MouseEvent MouseUp; MouseEvent MouseMove; + using ScrollWheelEvent = LvtkEvent; + + ScrollWheelEvent ScrollWheel; + using MouseOverEvent = LvtkEvent; MouseOverEvent MouseOver; MouseOverEvent MouseOut; @@ -138,6 +142,8 @@ namespace lvtk virtual bool OnMouseOver(LvtkMouseOverEventArgs &event); virtual bool OnMouseOut(LvtkMouseOverEventArgs &event); + virtual bool OnScrollWheel(LvtkScrollWheelEventArgs &event); + /// @brief Notification that a key was pressed. /// @param event Event arguments. @@ -174,6 +180,7 @@ namespace lvtk virtual bool FireMouseDown(LvtkMouseEventArgs&event); virtual bool FireMouseUp(LvtkMouseEventArgs&event); virtual void UpdateMouseOver(LvtkPoint mousePosition); + virtual bool FireScrollWheel(LvtkScrollWheelEventArgs&event); void SetMouseOver(bool mouseOver); diff --git a/src/lvtk/include/lvtk/LvtkFlexGridElement.hpp b/src/lvtk/include/lvtk/LvtkFlexGridElement.hpp index adffaaa..5fe5d0f 100644 --- a/src/lvtk/include/lvtk/LvtkFlexGridElement.hpp +++ b/src/lvtk/include/lvtk/LvtkFlexGridElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkGroupElement.hpp b/src/lvtk/include/lvtk/LvtkGroupElement.hpp index b1e5a43..7f9d388 100644 --- a/src/lvtk/include/lvtk/LvtkGroupElement.hpp +++ b/src/lvtk/include/lvtk/LvtkGroupElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkHorizontalStackElement.hpp b/src/lvtk/include/lvtk/LvtkHorizontalStackElement.hpp index bac53e5..95b86f2 100644 --- a/src/lvtk/include/lvtk/LvtkHorizontalStackElement.hpp +++ b/src/lvtk/include/lvtk/LvtkHorizontalStackElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkIndefiniteProgressElement.hpp b/src/lvtk/include/lvtk/LvtkIndefiniteProgressElement.hpp index f3734bf..66738d7 100644 --- a/src/lvtk/include/lvtk/LvtkIndefiniteProgressElement.hpp +++ b/src/lvtk/include/lvtk/LvtkIndefiniteProgressElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkLampElement.hpp b/src/lvtk/include/lvtk/LvtkLampElement.hpp index e74945a..e6c36de 100644 --- a/src/lvtk/include/lvtk/LvtkLampElement.hpp +++ b/src/lvtk/include/lvtk/LvtkLampElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkLog.hpp b/src/lvtk/include/lvtk/LvtkLog.hpp index 938a2fe..e8d4af4 100644 --- a/src/lvtk/include/lvtk/LvtkLog.hpp +++ b/src/lvtk/include/lvtk/LvtkLog.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkMarkdownElement.hpp b/src/lvtk/include/lvtk/LvtkMarkdownElement.hpp new file mode 100644 index 0000000..abb13be --- /dev/null +++ b/src/lvtk/include/lvtk/LvtkMarkdownElement.hpp @@ -0,0 +1,63 @@ +/* +Copyright (c) 2023 Robin E. R. Davies + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#pragma once + +#include "LvtkVerticalStackElement.hpp" +#include "LvtkTypographyElement.hpp" +#include +#include + +namespace lvtk { + class LvtkMarkdownElement: public LvtkVerticalStackElement { + public: + using self=LvtkMarkdownElement; + using super=LvtkContainerElement; + using ptr=std::shared_ptr; + static ptr Create() { return std::make_shared(); } + + LvtkMarkdownElement(); + LvtkMarkdownElement &TextVariant(LvtkTypographyVariant textVariant); + LvtkTypographyVariant TextVariant() const; + + void SetMarkdown(const std::string &text); + void SetMarkdown(std::istream&s); + void AddMarkdownFile(const std::filesystem::path &path); + + void AddMarkdownLine(const std::string &text); + void FlushMarkdown(); + private: + + struct HangingIndentState { + double indentMargin; + size_t indentCharacters; + }; + + std::vector hangingIndentStack; + + LvtkTypographyVariant textVariant = LvtkTypographyVariant::BodyPrimary; + std::string lineBuffer; + std::string hangingText; + double leftMargin = 0; + size_t hangingIndentChars = 0; + + bool lineBreak = false; + }; +} \ No newline at end of file diff --git a/src/lvtk/include/lvtk/LvtkMessageDialog.hpp b/src/lvtk/include/lvtk/LvtkMessageDialog.hpp index f01e95b..fbc3f18 100644 --- a/src/lvtk/include/lvtk/LvtkMessageDialog.hpp +++ b/src/lvtk/include/lvtk/LvtkMessageDialog.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkMotionBlurElement.hpp b/src/lvtk/include/lvtk/LvtkMotionBlurElement.hpp index 3b77a30..0b4987c 100644 --- a/src/lvtk/include/lvtk/LvtkMotionBlurElement.hpp +++ b/src/lvtk/include/lvtk/LvtkMotionBlurElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkNumericEditBoxElement.hpp b/src/lvtk/include/lvtk/LvtkNumericEditBoxElement.hpp index 9560fa4..5886925 100644 --- a/src/lvtk/include/lvtk/LvtkNumericEditBoxElement.hpp +++ b/src/lvtk/include/lvtk/LvtkNumericEditBoxElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkObject.hpp b/src/lvtk/include/lvtk/LvtkObject.hpp index 704a113..a2b4e36 100644 --- a/src/lvtk/include/lvtk/LvtkObject.hpp +++ b/src/lvtk/include/lvtk/LvtkObject.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkOnOffSwitchElement.hpp b/src/lvtk/include/lvtk/LvtkOnOffSwitchElement.hpp index 67caa60..80f1c22 100644 --- a/src/lvtk/include/lvtk/LvtkOnOffSwitchElement.hpp +++ b/src/lvtk/include/lvtk/LvtkOnOffSwitchElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkPangoContext.hpp b/src/lvtk/include/lvtk/LvtkPangoContext.hpp index cd41ed9..90be65f 100644 --- a/src/lvtk/include/lvtk/LvtkPangoContext.hpp +++ b/src/lvtk/include/lvtk/LvtkPangoContext.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkPngDialElement.hpp b/src/lvtk/include/lvtk/LvtkPngDialElement.hpp index 4bb1a46..b923c60 100644 --- a/src/lvtk/include/lvtk/LvtkPngDialElement.hpp +++ b/src/lvtk/include/lvtk/LvtkPngDialElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkPngElement.hpp b/src/lvtk/include/lvtk/LvtkPngElement.hpp index 8d045f8..b2831cd 100644 --- a/src/lvtk/include/lvtk/LvtkPngElement.hpp +++ b/src/lvtk/include/lvtk/LvtkPngElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkPngStripElement.hpp b/src/lvtk/include/lvtk/LvtkPngStripElement.hpp index 63de07a..b9f3c2a 100644 --- a/src/lvtk/include/lvtk/LvtkPngStripElement.hpp +++ b/src/lvtk/include/lvtk/LvtkPngStripElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkRootElement.hpp b/src/lvtk/include/lvtk/LvtkRootElement.hpp index 98abfc3..e6f07cb 100644 --- a/src/lvtk/include/lvtk/LvtkRootElement.hpp +++ b/src/lvtk/include/lvtk/LvtkRootElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkScrollBarElement.hpp b/src/lvtk/include/lvtk/LvtkScrollBarElement.hpp index 49ca44b..3bc27da 100644 --- a/src/lvtk/include/lvtk/LvtkScrollBarElement.hpp +++ b/src/lvtk/include/lvtk/LvtkScrollBarElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkScrollContainerElement.hpp b/src/lvtk/include/lvtk/LvtkScrollContainerElement.hpp index dee1670..d8c96f6 100644 --- a/src/lvtk/include/lvtk/LvtkScrollContainerElement.hpp +++ b/src/lvtk/include/lvtk/LvtkScrollContainerElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -104,6 +104,8 @@ namespace lvtk void ScrollIntoView(LvtkElement *element, LvtkThickness surroundingSpace); protected: + virtual bool OnScrollWheel(LvtkScrollWheelEventArgs &event) override; + virtual bool ClipChildren() const override; virtual void OnHorizontalScrollEnableChanged(bool value); diff --git a/src/lvtk/include/lvtk/LvtkSlideInOutAnimationElement.hpp b/src/lvtk/include/lvtk/LvtkSlideInOutAnimationElement.hpp index 50640ef..0f68be0 100644 --- a/src/lvtk/include/lvtk/LvtkSlideInOutAnimationElement.hpp +++ b/src/lvtk/include/lvtk/LvtkSlideInOutAnimationElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkStatusTextElement.hpp b/src/lvtk/include/lvtk/LvtkStatusTextElement.hpp index 5df058b..0ea39d3 100644 --- a/src/lvtk/include/lvtk/LvtkStatusTextElement.hpp +++ b/src/lvtk/include/lvtk/LvtkStatusTextElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkStyle.hpp b/src/lvtk/include/lvtk/LvtkStyle.hpp index 24bc045..d3746b7 100644 --- a/src/lvtk/include/lvtk/LvtkStyle.hpp +++ b/src/lvtk/include/lvtk/LvtkStyle.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -59,6 +59,8 @@ namespace lvtk self &HorizontalAlignment(LvtkAlignment alignment); self &VerticalAlignment(LvtkAlignment alignment); + + LvtkThicknessMeasurement Margin() const; self &Margin(const LvtkThicknessMeasurement &value); self &MarginLeft(const LvtkMeasurement &value); self &MarginTop(const LvtkMeasurement &value); @@ -67,6 +69,8 @@ namespace lvtk self &MarginStart(const LvtkMeasurement &value); self &MarginEnd(const LvtkMeasurement &value); + + LvtkThicknessMeasurement BorderWidth() const; self &BorderWidth(const LvtkThicknessMeasurement &value); self &BorderWidthLeft(const LvtkMeasurement &value); self &BorderWidthTop(const LvtkMeasurement &value); @@ -75,6 +79,7 @@ namespace lvtk self &BorderWidthStart(const LvtkMeasurement &value); self &BorderWidthEnd(const LvtkMeasurement &value); + LvtkThicknessMeasurement Padding() const; self &Padding(const LvtkThicknessMeasurement &value); self &PaddingLeft(const LvtkMeasurement &value); self &PaddingTop(const LvtkMeasurement &value); @@ -83,6 +88,16 @@ namespace lvtk self &PaddingStart(const LvtkMeasurement &value); self &PaddingEnd(const LvtkMeasurement &value); + LvtkThicknessMeasurement CellPadding() const; + self &CellPadding(const LvtkThicknessMeasurement &value); + self &CellPaddingLeft(const LvtkMeasurement &value); + self &CellPaddingTop(const LvtkMeasurement &value); + self &CellPaddingRight(const LvtkMeasurement &value); + self &CellPaddingBottom(const LvtkMeasurement &value); + self &CellPaddingStart(const LvtkMeasurement &value); + self &CellPaddingEnd(const LvtkMeasurement &value); + + self &BorderColor(const LvtkPattern &pattern); self &Background(const LvtkPattern &pattern); self &Color(const LvtkPattern &pattern); @@ -134,10 +149,7 @@ namespace lvtk LvtkMeasurement Height() const; LvtkMeasurement FontSize() const; - LvtkThicknessMeasurement Margin() const; - LvtkThicknessMeasurement Padding() const; - LvtkThicknessMeasurement BorderWidth() const; const LvtkPattern &Background() const; const LvtkPattern &BorderColor() const; @@ -174,11 +186,11 @@ namespace lvtk self &TextAlign(LvtkTextAlign value); LvtkTextAlign TextAlign() const; - self &FlexRowGap(const LvtkMeasurement &value); - LvtkMeasurement FlexRowGap() const; + self &RowGap(const LvtkMeasurement &value); + LvtkMeasurement RowGap() const; - self &FlexColumnGap(const LvtkMeasurement &value); - LvtkMeasurement FlexColumnGap() const; + self &ColumnGap(const LvtkMeasurement &value); + LvtkMeasurement ColumnGap() const; self &Opacity(double value); double Opacity() const; @@ -257,6 +269,7 @@ namespace lvtk std::optional margin; std::optional borderWidth; std::optional padding; + std::optional cellPadding; LvtkPattern borderColor; LvtkPattern background; LvtkPattern color; diff --git a/src/lvtk/include/lvtk/LvtkSvg.hpp b/src/lvtk/include/lvtk/LvtkSvg.hpp index 4d26020..a6bd8c9 100644 --- a/src/lvtk/include/lvtk/LvtkSvg.hpp +++ b/src/lvtk/include/lvtk/LvtkSvg.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkSvgElement.hpp b/src/lvtk/include/lvtk/LvtkSvgElement.hpp index 31942d9..4a9d77f 100644 --- a/src/lvtk/include/lvtk/LvtkSvgElement.hpp +++ b/src/lvtk/include/lvtk/LvtkSvgElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkSwitchElement.hpp b/src/lvtk/include/lvtk/LvtkSwitchElement.hpp index 0e6f179..2d5b081 100644 --- a/src/lvtk/include/lvtk/LvtkSwitchElement.hpp +++ b/src/lvtk/include/lvtk/LvtkSwitchElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkTableElement.hpp b/src/lvtk/include/lvtk/LvtkTableElement.hpp new file mode 100644 index 0000000..8fa6a14 --- /dev/null +++ b/src/lvtk/include/lvtk/LvtkTableElement.hpp @@ -0,0 +1,72 @@ +// Copyright (c) 2023 Robin E. R. Davies +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#pragma once + +#include "LvtkContainerElement.hpp" +#include + + +namespace lvtk { + struct LvtkColumnDefinition { + LvtkAlignment rowAlignment = LvtkAlignment::Start; + LvtkAlignment columnAlignment = LvtkAlignment::Start; + double columnWidth = 0; + }; + class LvtkTableElement : public LvtkContainerElement { + public: + using self = LvtkTableElement; + using super = LvtkElement; + using ptr = std::shared_ptr; + + static ptr Create() { return std::make_shared(); } + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Woverloaded-virtual" + + LvtkElement::ptr&Child(size_t row, size_t column); + + +#pragma GCC diagnostic pop + public: + size_t ColumnCount() const; + LvtkTableElement &ColumnCount(size_t columns); + size_t RowCount() const; + + std::vector &ColumnDefinitions(); + LvtkTableElement& ColumnDefinitions(const std::vector &columnDefinitions); + LvtkTableElement& ColumnDefinitions(std::vector &&columnDefinitions); + + LvtkTableElement&AddRow(const std::vector&children); + LvtkTableElement&AddRow(std::vector&&children); + + public: + virtual LvtkSize Arrange(LvtkSize available,LvtkDrawingContext &context) override; + protected: + virtual LvtkSize MeasureClient(LvtkSize clientConstraint, LvtkSize clientAvailable,LvtkDrawingContext&context) override; + + virtual void OnDraw(LvtkDrawingContext &dc) override; + + private: + std::vector columnDefinitions; + + std::vector columnWidths; + std::vector rowHeights; + }; +} \ No newline at end of file diff --git a/src/lvtk/include/lvtk/LvtkTheme.hpp b/src/lvtk/include/lvtk/LvtkTheme.hpp index d5fdb53..f97a4e8 100644 --- a/src/lvtk/include/lvtk/LvtkTheme.hpp +++ b/src/lvtk/include/lvtk/LvtkTheme.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkTypes.hpp b/src/lvtk/include/lvtk/LvtkTypes.hpp index 0d07f5e..bb10f5f 100644 --- a/src/lvtk/include/lvtk/LvtkTypes.hpp +++ b/src/lvtk/include/lvtk/LvtkTypes.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -65,6 +65,8 @@ namespace lvtk } + LvtkSize operator+(const LvtkSize&other) { return LvtkSize(width+other.width,height+other.height);} + LvtkSize operator-(const LvtkSize&other) { return LvtkSize(width-other.width,height-other.height);} LvtkSize operator/(double value) const { return LvtkSize(width/value,height/value); } LvtkSize operator*(double value) const { return LvtkSize(width*value,height*value); } LvtkSize ceil() const { return LvtkSize(std::ceil(width),std::ceil(height));} @@ -577,6 +579,29 @@ namespace lvtk unsigned int keysym = 0; ModifierState modifierState; }; + enum class LvtkScrollDirection { + Up, + Down, + Left, + Right + }; + struct LvtkScrollWheelEventArgs + { + public: + LvtkScrollWheelEventArgs(); + LvtkScrollWheelEventArgs(WindowHandle h, LvtkScrollDirection scrollDirection, double x, double y, ModifierState modifierState); + + WindowHandle h; + LvtkScrollDirection scrollDirection; + + // Mouse location in element coordinates. + LvtkPoint point; + // Mouse location in screeen coordinates. + LvtkPoint screenPoint; + ModifierState modifierState; + }; + + struct LvtkMouseEventArgs { public: @@ -613,6 +638,14 @@ namespace lvtk : h(WindowHandle(0)), button(0), point({0, 0}), screenPoint({0, 0}), modifierState(ModifierState::Empty) { } + inline LvtkScrollWheelEventArgs::LvtkScrollWheelEventArgs(WindowHandle h, LvtkScrollDirection scrollDirection, double x, double y, ModifierState modifierState) + : h(h), scrollDirection(scrollDirection), point({-1, -1}), screenPoint({double(x), double(y)}), modifierState(modifierState) + { + } + inline LvtkScrollWheelEventArgs::LvtkScrollWheelEventArgs() + : h(WindowHandle(0)), scrollDirection(LvtkScrollDirection::Up), point({0, 0}), screenPoint({0, 0}), modifierState(ModifierState::Empty) + { + } inline bool LvtkRectangle::operator==(const LvtkRectangle &other) const { diff --git a/src/lvtk/include/lvtk/LvtkTypographyElement.hpp b/src/lvtk/include/lvtk/LvtkTypographyElement.hpp index e786701..25325dc 100644 --- a/src/lvtk/include/lvtk/LvtkTypographyElement.hpp +++ b/src/lvtk/include/lvtk/LvtkTypographyElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -77,6 +77,8 @@ namespace lvtk protected: void OnTextChanged(const std::string&text); void OnVariantChanged(LvtkTypographyVariant value); + void OnMount() override; + private: IcuString::Ptr icuString; bool SingleLine() const; @@ -88,7 +90,6 @@ namespace lvtk bool hasFixedLayout = false; LvtkSize clientMeasure; LvtkStyle::ptr GetVariantStyle(); - void OnMount(LvtkWindow*window) override; PangoFontDescription*GetFontDescription(); diff --git a/src/lvtk/include/lvtk/LvtkUserData.hpp b/src/lvtk/include/lvtk/LvtkUserData.hpp index 350ce9c..9cc25b7 100644 --- a/src/lvtk/include/lvtk/LvtkUserData.hpp +++ b/src/lvtk/include/lvtk/LvtkUserData.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkValueElement.hpp b/src/lvtk/include/lvtk/LvtkValueElement.hpp index 7ebd93c..bd2286a 100644 --- a/src/lvtk/include/lvtk/LvtkValueElement.hpp +++ b/src/lvtk/include/lvtk/LvtkValueElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkVerticalStackElement.hpp b/src/lvtk/include/lvtk/LvtkVerticalStackElement.hpp index 2e0c4b1..c2898f1 100644 --- a/src/lvtk/include/lvtk/LvtkVerticalStackElement.hpp +++ b/src/lvtk/include/lvtk/LvtkVerticalStackElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkVuElement.hpp b/src/lvtk/include/lvtk/LvtkVuElement.hpp index f227517..00e7666 100644 --- a/src/lvtk/include/lvtk/LvtkVuElement.hpp +++ b/src/lvtk/include/lvtk/LvtkVuElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/include/lvtk/LvtkWindow.hpp b/src/lvtk/include/lvtk/LvtkWindow.hpp index 03b2ebe..d7bc16e 100644 --- a/src/lvtk/include/lvtk/LvtkWindow.hpp +++ b/src/lvtk/include/lvtk/LvtkWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -177,6 +177,7 @@ namespace lvtk void Close(); + void CloseRootWindow(); WindowHandle Handle() const; @@ -315,6 +316,7 @@ namespace lvtk virtual bool OnMouseDown(LvtkMouseEventArgs &event); virtual bool OnMouseMove(LvtkMouseEventArgs &event); virtual bool OnMouseUp(LvtkMouseEventArgs &event); + virtual bool OnScrollWheel(LvtkScrollWheelEventArgs &event); virtual void OnIdle(); virtual void OnSizeChanged(const LvtkSize &size); @@ -353,6 +355,7 @@ namespace lvtk // Native Window callback. void OnExpose(WindowHandle h, int64_t x, int64_t y, int64_t width, int64_t height); virtual void MouseDown(WindowHandle h, uint64_t button, int64_t x, int64_t y, ModifierState state); + virtual void MouseScrollWheel(WindowHandle h, LvtkScrollDirection direction, int64_t x, int64_t y, ModifierState state); virtual void MouseMove(WindowHandle h, int64_t x, int64_t y, ModifierState state); virtual void MouseUp(WindowHandle h, uint64_t button, int64_t x, int64_t y, ModifierState state); virtual void MouseLeave(WindowHandle h); diff --git a/src/lvtk/keysym_names.cpp b/src/lvtk/keysym_names.cpp index 693264a..bf4db2e 100644 --- a/src/lvtk/keysym_names.cpp +++ b/src/lvtk/keysym_names.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/keysym_names.hpp b/src/lvtk/keysym_names.hpp index 7f31736..a60139d 100644 --- a/src/lvtk/keysym_names.hpp +++ b/src/lvtk/keysym_names.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk/ss.hpp b/src/lvtk/ss.hpp index 7436111..65a920f 100644 --- a/src/lvtk/ss.hpp +++ b/src/lvtk/ss.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/CMakeLists.txt b/src/lvtk_ui/CMakeLists.txt index 4a24d20..675d73f 100644 --- a/src/lvtk_ui/CMakeLists.txt +++ b/src/lvtk_ui/CMakeLists.txt @@ -17,7 +17,7 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") -add_library(lvtk_ui STATIC +add_library(lvtk_ui OBJECT include/lvtk_ui/Lv2ControlConstants.hpp include/lvtk_ui/Lv2PortViewFactory.hpp include/lvtk_ui/Lv2PluginType.hpp @@ -37,7 +37,6 @@ add_library(lvtk_ui STATIC Lv2FileDialog.cpp GlobMatcher.cpp MimeTypes.cpp - PiPedalUI.cpp Lv2PluginInfo.cpp Lv2PortViewFactory.cpp Lv2PluginType.cpp @@ -46,10 +45,18 @@ add_library(lvtk_ui STATIC Lv2UI.cpp Lv2UI_glue.cpp Lv2Units.cpp + PiPedalUI.cpp + ss.hpp ) +message(STATUS "lvtk_ui CMAKE_DEB_HOST_ARCH: ${CMAKE_DEB_HOST_ARCH}") +message(STATUS "lvtk_ui CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") +message(STATUS "lvtk_ui CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") + + + set(LV2CAIRO_UI_INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include" ) target_include_directories(lvtk_ui PUBLIC diff --git a/src/lvtk_ui/GlobMatcher.cpp b/src/lvtk_ui/GlobMatcher.cpp index 29e4723..584e7b9 100644 --- a/src/lvtk_ui/GlobMatcher.cpp +++ b/src/lvtk_ui/GlobMatcher.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/src/lvtk_ui/Lv2FileDialog.cpp b/src/lvtk_ui/Lv2FileDialog.cpp index c2973e0..fa0f979 100644 --- a/src/lvtk_ui/Lv2FileDialog.cpp +++ b/src/lvtk_ui/Lv2FileDialog.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby gra nted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -586,7 +586,7 @@ LvtkElement::ptr Lv2FileDialog::RenderBreadcrumb( auto flexGrid = LvtkFlexGridElement::Create(); flexGrid->Style() .FlexAlignItems(LvtkAlignment::Center) - .FlexColumnGap(4); + .ColumnGap(4); if (icon.length() != 0) { auto element = LvtkSvgElement::Create(); @@ -831,7 +831,7 @@ LvtkElement::ptr Lv2FileDialog::RenderTopPanel() .FlexDirection(LvtkFlexDirection::Row) .FlexWrap(LvtkFlexWrap::NoWrap) .Padding({8, 4, 8, 4}) - .FlexRowGap(8); + .RowGap(8); { auto undoContainer = LvtkFlexGridElement::Create(); { @@ -929,8 +929,8 @@ LvtkElement::ptr Lv2FileDialog::RenderFileList() .Padding({8, 8, 8, 24}) .FlexDirection(LvtkFlexDirection::Column) .FlexWrap(LvtkFlexWrap::Wrap) - .FlexColumnGap(16) - .FlexRowGap(0); + .ColumnGap(16) + .RowGap(0); scroll->Child(body); } container->AddChild(scroll); @@ -1015,7 +1015,7 @@ LvtkElement::ptr Lv2FileDialog::RenderPanel(size_t index, const FilePanel &locat .FlexDirection(LvtkFlexDirection::Row) .FlexWrap(LvtkFlexWrap::NoWrap) .FlexAlignItems(LvtkAlignment::Center) - .FlexColumnGap(8) + .ColumnGap(8) .Padding({16, 8, 16, 8}); { auto icon = LvtkSvgElement::Create(); @@ -1097,7 +1097,7 @@ LvtkElement::ptr Lv2FileDialog::RenderFooter() .FlexAlignItems(LvtkAlignment::Center) .FlexDirection(LvtkFlexDirection::Row) .FlexWrap(LvtkFlexWrap::NoWrap) - .FlexColumnGap(8) + .ColumnGap(8) .Padding({20, 16, 24, 16}) .BorderWidth({0, 1, 0, 0}) .BorderColor(Theme().dividerColor) @@ -1310,7 +1310,7 @@ void Lv2FileDialog::LoadMixedDirectoryFiles(const std::vector &file auto container = LvtkFlexGridElement::Create(); container->Style() .FlexWrap(LvtkFlexWrap::NoWrap) - .FlexColumnGap(8) + .ColumnGap(8) .FlexAlignItems(LvtkAlignment::Start) .Padding({8, 4, 8, 4}); { @@ -1477,7 +1477,7 @@ void Lv2FileDialog::LoadFiles(const std::filesystem::path &path) auto container = LvtkFlexGridElement::Create(); container->Style() .FlexWrap(LvtkFlexWrap::NoWrap) - .FlexColumnGap(8) + .ColumnGap(8) .FlexAlignItems(LvtkAlignment::Center) .Padding({8, 4, 8, 4}); { diff --git a/src/lvtk_ui/Lv2FrequencyPlotElement.cpp b/src/lvtk_ui/Lv2FrequencyPlotElement.cpp index 7a0c665..f34bf63 100644 --- a/src/lvtk_ui/Lv2FrequencyPlotElement.cpp +++ b/src/lvtk_ui/Lv2FrequencyPlotElement.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -55,6 +55,9 @@ Lv2FrequencyPlotElement::Lv2FrequencyPlotElement(Lv2UI *lv2UI, const UiFrequency } void Lv2FrequencyPlotElement::PreComputeGridXs() { + majorGridXs.resize(0); + minorGridXs.resize(0); + double m = frequencyPlot.width() / (std::log(frequencyPlot.xRight()) - std::log(frequencyPlot.xLeft())); double gridX0 = std::pow(10, std::floor(std::log10(this->frequencyPlot.xLeft()))); @@ -123,26 +126,44 @@ void Lv2FrequencyPlotElement::OnValuesChanged(const void *data) { size_t count = (atomVector->atom.size - sizeof(LV2_Atom_Vector_Body)) / atomVector->body.child_size; const float *newValues = (const float *)((const uint8_t *)data + sizeof(LV2_Atom_Vector)); - if (count == this->values.size()) + + bool axesChanged = true; + if (count == this->values.size() + 4) { bool changed = false; - for (size_t i = 0; i < count; ++i) + axesChanged = false; + axesChanged + = frequencyPlot.xLeft() != newValues[0] + || frequencyPlot.xRight() != newValues[1] + || frequencyPlot.yTop() != newValues[2] + || frequencyPlot.yBottom() != newValues[3]; + + for (size_t i = 0; i < values.size(); ++i) { - if (this->values[i] != newValues[i]) + if (this->values[i] != newValues[i+4]) { changed = true; break; } } - if (!changed) + if (!changed && !axesChanged) { return; } } - this->values.resize(count); - for (size_t i = 0; i < count; ++i) + + if (axesChanged) + { + frequencyPlot.xLeft(newValues[0]); + frequencyPlot.xRight(newValues[1]); + frequencyPlot.yTop(newValues[2]); + frequencyPlot.yBottom(newValues[3]); + PreComputeGridXs(); + } + this->values.resize(count-4); + for (size_t i = 0; i < this->values.size(); ++i) { - this->values[i] = newValues[i]; + this->values[i] = newValues[i+4]; } Invalidate(); } diff --git a/src/lvtk_ui/Lv2PluginInfo.cpp b/src/lvtk_ui/Lv2PluginInfo.cpp index 3136d7f..d3d66e5 100644 --- a/src/lvtk_ui/Lv2PluginInfo.cpp +++ b/src/lvtk_ui/Lv2PluginInfo.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/Lv2PluginType.cpp b/src/lvtk_ui/Lv2PluginType.cpp index 318c83b..f76bffc 100644 --- a/src/lvtk_ui/Lv2PluginType.cpp +++ b/src/lvtk_ui/Lv2PluginType.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/Lv2PortView.cpp b/src/lvtk_ui/Lv2PortView.cpp index 41dfd74..6398b97 100644 --- a/src/lvtk_ui/Lv2PortView.cpp +++ b/src/lvtk_ui/Lv2PortView.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/Lv2PortViewController.cpp b/src/lvtk_ui/Lv2PortViewController.cpp index b1b92c9..1acf74c 100644 --- a/src/lvtk_ui/Lv2PortViewController.cpp +++ b/src/lvtk_ui/Lv2PortViewController.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/Lv2PortViewFactory.cpp b/src/lvtk_ui/Lv2PortViewFactory.cpp index dbc04ee..7db33c5 100644 --- a/src/lvtk_ui/Lv2PortViewFactory.cpp +++ b/src/lvtk_ui/Lv2PortViewFactory.cpp @@ -561,8 +561,8 @@ LvtkContainerElement::ptr Lv2PortViewFactory::CreatePage() .HorizontalAlignment(LvtkAlignment::Stretch) .VerticalAlignment(LvtkAlignment::Stretch) .Padding({24, 16, 24, 16}) - .FlexRowGap(16) - .FlexColumnGap(8) + .RowGap(16) + .ColumnGap(8) .FlexAlignItems(LvtkAlignment::Center) .Background(Theme().paper) .FlexWrap(LvtkFlexWrap::Wrap); diff --git a/src/lvtk_ui/Lv2UI.cpp b/src/lvtk_ui/Lv2UI.cpp index 2548f14..cfe39e9 100644 --- a/src/lvtk_ui/Lv2UI.cpp +++ b/src/lvtk_ui/Lv2UI.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -41,6 +41,7 @@ #include "lv2/options/options.h" #include #include +#include #include #include @@ -67,7 +68,7 @@ void Lv2UI::SetCreateWindowDefaults() } if (params.minSize == LvtkSize::Zero) { - params.minSize = LvtkSize(320, 200); + params.minSize = LvtkSize(320, std::min(params.size.Height(),200.0)); } if (params.maxSize == LvtkSize::Zero) { diff --git a/src/lvtk_ui/Lv2UI_glue.cpp b/src/lvtk_ui/Lv2UI_glue.cpp index 66374c0..acc5780 100644 --- a/src/lvtk_ui/Lv2UI_glue.cpp +++ b/src/lvtk_ui/Lv2UI_glue.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -173,6 +173,7 @@ Lv2UIRegistrationBase::~Lv2UIRegistrationBase() { } + // The main LV2 entry point. LV2_SYMBOL_EXPORT const LV2UI_Descriptor * @@ -180,6 +181,7 @@ lv2ui_descriptor(uint32_t index) { if (descriptors.size() == 0) { + for (size_t i = 0; i < gRegistrationCount; ++i) { auto registration = gRegistrations[i]; diff --git a/src/lvtk_ui/Lv2Units.cpp b/src/lvtk_ui/Lv2Units.cpp index 87e5a63..cc5b2d5 100644 --- a/src/lvtk_ui/Lv2Units.cpp +++ b/src/lvtk_ui/Lv2Units.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/MimeTypes.cpp b/src/lvtk_ui/MimeTypes.cpp index ab27ded..533b69a 100644 --- a/src/lvtk_ui/MimeTypes.cpp +++ b/src/lvtk_ui/MimeTypes.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -24,9 +24,9 @@ using namespace lvtk::ui; #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#ifndef __clang__ #pragma GCC optimize("no-var-tracking") // to speed up compilation - +#endif void MimeTypes::MaybeInitialize() { diff --git a/src/lvtk_ui/PiPedalUI.cpp b/src/lvtk_ui/PiPedalUI.cpp index 93ebc21..19b0e89 100644 --- a/src/lvtk_ui/PiPedalUI.cpp +++ b/src/lvtk_ui/PiPedalUI.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -40,9 +40,9 @@ UiFileProperty::UiFileProperty(const std::string &name, const std::string &patch // } PiPedalUI::PiPedalUI( - std::vector &&fileProperties, - std::vector &&frequencyPlots, - std::vector &&portNotifications) + std::vector &&fileProperties, + std::vector &&frequencyPlots, + std::vector &&portNotifications) { this->fileProperties_ = std::move(fileProperties); diff --git a/src/lvtk_ui/include/lvtk_ui/GlobMatcher.hpp b/src/lvtk_ui/include/lvtk_ui/GlobMatcher.hpp index cbd7ae1..8f16b77 100644 --- a/src/lvtk_ui/include/lvtk_ui/GlobMatcher.hpp +++ b/src/lvtk_ui/include/lvtk_ui/GlobMatcher.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2ControlConstants.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2ControlConstants.hpp index ca10727..27b98aa 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2ControlConstants.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2ControlConstants.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2Exception.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2Exception.hpp index 881507e..b3178f4 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2Exception.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2Exception.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2FileDialog.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2FileDialog.hpp index 292dc5a..a1b1301 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2FileDialog.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2FileDialog.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2FrequencyPlotElement.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2FrequencyPlotElement.hpp index 4517d1b..cfbf3b8 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2FrequencyPlotElement.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2FrequencyPlotElement.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -24,6 +24,9 @@ namespace lvtk::ui { + /// Element that display a frequency-response graph. + /// + /// class Lv2FrequencyPlotElement: public LvtkElement { public: using self=Lv2FrequencyPlotElement; @@ -52,7 +55,7 @@ namespace lvtk::ui { void OnValuesChanged(const void*value); Lv2UI*lv2UI = nullptr; - const UiFrequencyPlot frequencyPlot; + UiFrequencyPlot frequencyPlot; std::vector values; std::vector majorGridXs; std::vector minorGridXs; diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2PluginInfo.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2PluginInfo.hpp index daa013a..42cecaf 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2PluginInfo.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2PluginInfo.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2PluginType.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2PluginType.hpp index 37bbee6..7606070 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2PluginType.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2PluginType.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2PortView.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2PortView.hpp index 9d323dc..2943ee7 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2PortView.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2PortView.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2PortViewController.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2PortViewController.hpp index e06cca1..7a646ae 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2PortViewController.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2PortViewController.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2PortViewFactory.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2PortViewFactory.hpp index 8cdf950..88eb66d 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2PortViewFactory.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2PortViewFactory.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2UI.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2UI.hpp index fecdfa1..70858de 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2UI.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2UI.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2UI_NativeCallbacks.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2UI_NativeCallbacks.hpp index 0c65553..c5263b4 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2UI_NativeCallbacks.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2UI_NativeCallbacks.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/Lv2Units.hpp b/src/lvtk_ui/include/lvtk_ui/Lv2Units.hpp index 713ae1d..e612f0a 100644 --- a/src/lvtk_ui/include/lvtk_ui/Lv2Units.hpp +++ b/src/lvtk_ui/include/lvtk_ui/Lv2Units.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -17,7 +17,7 @@ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/MimeTypes.hpp b/src/lvtk_ui/include/lvtk_ui/MimeTypes.hpp index eaf97a2..88219fb 100644 --- a/src/lvtk_ui/include/lvtk_ui/MimeTypes.hpp +++ b/src/lvtk_ui/include/lvtk_ui/MimeTypes.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/lvtk_ui/include/lvtk_ui/PiPedalUI.hpp b/src/lvtk_ui/include/lvtk_ui/PiPedalUI.hpp index 4bffd8f..0ab438c 100644 --- a/src/lvtk_ui/include/lvtk_ui/PiPedalUI.hpp +++ b/src/lvtk_ui/include/lvtk_ui/PiPedalUI.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -179,10 +179,14 @@ namespace lvtk::ui { int32_t index() const { return index_; } const std::string&portGroup() const { return portGroup_; } float xLeft() const { return xLeft_; } + void xLeft(float value) { xLeft_ = value;} float xRight() const { return xRight_; } + void xRight(float value) { xRight_ = value; } bool xLog() const { return xLog_; } float yTop() const { return yTop_; } + void yTop(float value) { yTop_ = value; } float yBottom() const { return yBottom_; } + void yBottom(float value) { yBottom_ = value; } bool yDb() const { return yDb_; } float width() const { return width_; } diff --git a/src/lvtk_ui/ss.hpp b/src/lvtk_ui/ss.hpp index 7436111..65a920f 100644 --- a/src/lvtk_ui/ss.hpp +++ b/src/lvtk_ui/ss.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/BindingTest.cpp b/src/test/BindingTest.cpp index 5a41bdb..2e727cc 100644 --- a/src/test/BindingTest.cpp +++ b/src/test/BindingTest.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/ButtonTestPage.cpp b/src/test/ButtonTestPage.cpp index af60c3c..9e48e57 100644 --- a/src/test/ButtonTestPage.cpp +++ b/src/test/ButtonTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -211,7 +211,7 @@ LvtkElement::ptr ButtonTestPage::CreatePageView(LvtkTheme::ptr theme) } { auto flexGrid = LvtkFlexGridElement::Create(); flexGrid->Style() - .FlexColumnGap(8) + .ColumnGap(8) .FlexAlignItems(LvtkAlignment::Center) .FlexJustification(LvtkFlexJustification::Start) .FlexWrap(LvtkFlexWrap::NoWrap) @@ -243,7 +243,7 @@ LvtkElement::ptr ButtonTestPage::CreatePageView(LvtkTheme::ptr theme) auto flexGrid = LvtkFlexGridElement::Create(); main->AddChild(flexGrid); flexGrid->Style() - .FlexColumnGap(8) + .ColumnGap(8) .FlexAlignItems(LvtkAlignment::Center) .FlexJustification(LvtkFlexJustification::Start) .FlexWrap(LvtkFlexWrap::NoWrap) @@ -273,7 +273,7 @@ LvtkElement::ptr ButtonTestPage::CreatePageView(LvtkTheme::ptr theme) if (true ){ auto flexGrid = LvtkFlexGridElement::Create(); flexGrid->Style() - .FlexColumnGap(8) + .ColumnGap(8) .FlexAlignItems(LvtkAlignment::Center) .FlexJustification(LvtkFlexJustification::Start) .FlexWrap(LvtkFlexWrap::NoWrap) @@ -316,7 +316,7 @@ LvtkElement::ptr ButtonTestPage::CreatePageView(LvtkTheme::ptr theme) if (true ){ auto flexGrid = LvtkFlexGridElement::Create(); flexGrid->Style() - .FlexColumnGap(8) + .ColumnGap(8) .FlexAlignItems(LvtkAlignment::Center) .FlexJustification(LvtkFlexJustification::Start) .FlexWrap(LvtkFlexWrap::NoWrap) @@ -389,7 +389,7 @@ LvtkElement::ptr ButtonTestPage::CreatePageView(LvtkTheme::ptr theme) auto flexGrid = LvtkFlexGridElement::Create(); main->AddChild(flexGrid); flexGrid->Style() - .FlexColumnGap(8) + .ColumnGap(8) .FlexAlignItems(LvtkAlignment::Center) .FlexJustification(LvtkFlexJustification::Start) .FlexWrap(LvtkFlexWrap::NoWrap) @@ -417,7 +417,7 @@ LvtkElement::ptr ButtonTestPage::CreatePageView(LvtkTheme::ptr theme) auto flexGrid = LvtkFlexGridElement::Create(); main->AddChild(flexGrid); flexGrid->Style() - .FlexColumnGap(24) + .ColumnGap(24) .FlexAlignItems(LvtkAlignment::Center) .FlexJustification(LvtkFlexJustification::Start) .FlexWrap(LvtkFlexWrap::NoWrap) diff --git a/src/test/ButtonTestPage.hpp b/src/test/ButtonTestPage.hpp index 701787b..65f1be1 100644 --- a/src/test/ButtonTestPage.hpp +++ b/src/test/ButtonTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index ff8e48d..71875df 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -9,9 +9,11 @@ find_package(X11) add_executable(lvtk_demo + $ $ LvtkTestMain.cpp TestPage.hpp + TableTestPage.cpp TableTestPage.hpp PaletteTestPage.cpp PaletteTestPage.hpp Lv2UiTestPage.cpp Lv2UiTestPage.hpp SamplePluginInfo.hpp MotionBlurTestPage.cpp MotionBlurTestPage.hpp @@ -51,6 +53,8 @@ target_link_libraries(lvtk_demo ) add_executable(CatchTest + $ $ + MaterialColorTest.cpp TestMain.cpp ColorTest.cpp diff --git a/src/test/CapitalizationTest.cpp b/src/test/CapitalizationTest.cpp index 4a97eaa..7c1ca1e 100644 --- a/src/test/CapitalizationTest.cpp +++ b/src/test/CapitalizationTest.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/ColorTest.cpp b/src/test/ColorTest.cpp index eef3e88..84c2ec0 100644 --- a/src/test/ColorTest.cpp +++ b/src/test/ColorTest.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/DamageListTest.cpp b/src/test/DamageListTest.cpp index 66ac2f1..cac2881 100644 --- a/src/test/DamageListTest.cpp +++ b/src/test/DamageListTest.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/DialTestPage.cpp b/src/test/DialTestPage.cpp index 86d4ca5..9923551 100644 --- a/src/test/DialTestPage.cpp +++ b/src/test/DialTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/DialTestPage.hpp b/src/test/DialTestPage.hpp index 8c43817..cbbbc57 100644 --- a/src/test/DialTestPage.hpp +++ b/src/test/DialTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/DropShadowTestPage.cpp b/src/test/DropShadowTestPage.cpp index 6e87311..c004e67 100644 --- a/src/test/DropShadowTestPage.cpp +++ b/src/test/DropShadowTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -40,8 +40,8 @@ LvtkElement::ptr DropShadowTestPage::CreatePageView(LvtkTheme::ptr theme) .FlexWrap(LvtkFlexWrap::Wrap) .FlexDirection(LvtkFlexDirection::Row) .FlexAlignItems(LvtkAlignment::Center) - .FlexRowGap(16) - .FlexColumnGap(16) + .RowGap(16) + .ColumnGap(16) .HorizontalAlignment(LvtkAlignment::Stretch) .VerticalAlignment(LvtkAlignment::Stretch) diff --git a/src/test/DropShadowTestPage.hpp b/src/test/DropShadowTestPage.hpp index 2204f83..bd78b33 100644 --- a/src/test/DropShadowTestPage.hpp +++ b/src/test/DropShadowTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/DropdownTestPage.cpp b/src/test/DropdownTestPage.cpp index 3a6e273..12fa102 100644 --- a/src/test/DropdownTestPage.cpp +++ b/src/test/DropdownTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/DropdownTestPage.hpp b/src/test/DropdownTestPage.hpp index e31d1ef..dea23f9 100644 --- a/src/test/DropdownTestPage.hpp +++ b/src/test/DropdownTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/EditBoxTestPage.cpp b/src/test/EditBoxTestPage.cpp index eafd664..d0832a5 100644 --- a/src/test/EditBoxTestPage.cpp +++ b/src/test/EditBoxTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/EditBoxTestPage.hpp b/src/test/EditBoxTestPage.hpp index 55abebd..cb63322 100644 --- a/src/test/EditBoxTestPage.hpp +++ b/src/test/EditBoxTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/FlexGridTestPage.cpp b/src/test/FlexGridTestPage.cpp index 891f1dd..b365308 100644 --- a/src/test/FlexGridTestPage.cpp +++ b/src/test/FlexGridTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -233,11 +233,11 @@ FlexTestElement::FlexTestElement() element->ValueProperty.addObserver( [this](double value) { - grid->Style().FlexRowGap(value); + grid->Style().RowGap(value); grid->InvalidateLayout(); }) ); - controlGrid->AddChild(LabeledEditControl("FlexRowGap", element)); + controlGrid->AddChild(LabeledEditControl("RowGap", element)); } { auto element = LvtkNumericEditBoxElement::Create(); @@ -250,11 +250,11 @@ FlexTestElement::FlexTestElement() element->ValueProperty.addObserver( [this](double value) { - grid->Style().FlexColumnGap(value); + grid->Style().ColumnGap(value); grid->InvalidateLayout(); }) ); - controlGrid->AddChild(LabeledEditControl("FlexColumnGap", element)); + controlGrid->AddChild(LabeledEditControl("ColumnGap", element)); } stack->AddChild(controlGrid); diff --git a/src/test/FlexGridTestPage.hpp b/src/test/FlexGridTestPage.hpp index 233fbba..34e1418 100644 --- a/src/test/FlexGridTestPage.hpp +++ b/src/test/FlexGridTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/JsonTest.cpp b/src/test/JsonTest.cpp index b096ef8..9aa3171 100644 --- a/src/test/JsonTest.cpp +++ b/src/test/JsonTest.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/Lv2ControlTestPage.cpp b/src/test/Lv2ControlTestPage.cpp index c74dc0c..960bb0a 100644 --- a/src/test/Lv2ControlTestPage.cpp +++ b/src/test/Lv2ControlTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -52,7 +52,7 @@ LvtkElement::ptr Lv2ControlTestPage::CreatePageView(LvtkTheme::ptr theme) .Height(LvtkMeasurement::Percent(100)) .FlexWrap(LvtkFlexWrap::Wrap) .FlexAlignItems(LvtkAlignment::Center) - .FlexRowGap(16); + .RowGap(16); { auto element = LvtkTypographyElement::Create(); diff --git a/src/test/Lv2ControlTestPage.hpp b/src/test/Lv2ControlTestPage.hpp index 3137f2c..edc4ae3 100644 --- a/src/test/Lv2ControlTestPage.hpp +++ b/src/test/Lv2ControlTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/Lv2UiTestPage.cpp b/src/test/Lv2UiTestPage.cpp index 906cbb6..49ce497 100644 --- a/src/test/Lv2UiTestPage.cpp +++ b/src/test/Lv2UiTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/Lv2UiTestPage.hpp b/src/test/Lv2UiTestPage.hpp index fbfac42..cf38b18 100644 --- a/src/test/Lv2UiTestPage.hpp +++ b/src/test/Lv2UiTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/LvtkMinimumMain.cpp b/src/test/LvtkMinimumMain.cpp index 04148d0..90e4b42 100644 --- a/src/test/LvtkMinimumMain.cpp +++ b/src/test/LvtkMinimumMain.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/LvtkTestMain.cpp b/src/test/LvtkTestMain.cpp index db2ce42..7063e85 100644 --- a/src/test/LvtkTestMain.cpp +++ b/src/test/LvtkTestMain.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -27,6 +27,7 @@ #include "lvtk/LvtkSettingsFile.hpp" +#include "TableTestPage.hpp" #include "PaletteTestPage.hpp" #include "StandardDialogTestPage.hpp" #include "DialTestPage.hpp" @@ -178,6 +179,7 @@ void TestWindow::Render() pages.push_back(EditBoxTestPage::Create()); pages.push_back(TypographyTestPage::Create()); pages.push_back(FlexGridTestPage::Create()); + pages.push_back(TableTestPage::Create()); pages.push_back(ButtonTestPage::Create()); pages.push_back(SvgTestPage::Create()); pages.push_back(ScrollBarTestPage::Create()); @@ -355,6 +357,7 @@ void RequestRerender() { int main(int argc, char **argv) { + SetResourceDirectories(argv[0]); while (true) diff --git a/src/test/MotionBlurTestPage.cpp b/src/test/MotionBlurTestPage.cpp index 8e0320c..1c3538a 100644 --- a/src/test/MotionBlurTestPage.cpp +++ b/src/test/MotionBlurTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -48,8 +48,8 @@ LvtkElement::ptr MotionBlurTestPage::CreatePageView(LvtkTheme::ptr theme) .HorizontalAlignment(LvtkAlignment::Stretch) .FlexDirection(LvtkFlexDirection::Row) .FlexWrap(LvtkFlexWrap::Wrap) - .FlexColumnGap(16) - .FlexRowGap(16); + .ColumnGap(16) + .RowGap(16); LvtkSlideInOutAnimationElement::ptr slide; diff --git a/src/test/MotionBlurTestPage.hpp b/src/test/MotionBlurTestPage.hpp index 3ec6c93..97413e8 100644 --- a/src/test/MotionBlurTestPage.hpp +++ b/src/test/MotionBlurTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/PaletteTestPage.cpp b/src/test/PaletteTestPage.cpp index deb21d9..b8510b2 100644 --- a/src/test/PaletteTestPage.cpp +++ b/src/test/PaletteTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -112,7 +112,7 @@ LvtkElement::ptr PaletteTestPage::CreatePageView(LvtkTheme::ptr theme) main->Style() .Background(theme->paper) .Padding({24, 16, 24, 16}) - .FlexColumnGap(16) + .ColumnGap(16) .FlexDirection(LvtkFlexDirection::Row) .FlexWrap(LvtkFlexWrap::NoWrap); { diff --git a/src/test/PaletteTestPage.hpp b/src/test/PaletteTestPage.hpp index 933489d..c2bea85 100644 --- a/src/test/PaletteTestPage.hpp +++ b/src/test/PaletteTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/PngTestPage.cpp b/src/test/PngTestPage.cpp index 7fc5a77..e1258e9 100644 --- a/src/test/PngTestPage.cpp +++ b/src/test/PngTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/PngTestPage.hpp b/src/test/PngTestPage.hpp index 8e8a582..8d92a3c 100644 --- a/src/test/PngTestPage.hpp +++ b/src/test/PngTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/ScrollBarTestPage.cpp b/src/test/ScrollBarTestPage.cpp index 40c07a4..5dcd7d1 100644 --- a/src/test/ScrollBarTestPage.cpp +++ b/src/test/ScrollBarTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -79,7 +79,7 @@ LvtkElement::ptr IpsemLoremWide() container->Style() .FlexDirection(LvtkFlexDirection::Row) .FlexWrap(LvtkFlexWrap::NoWrap) - .FlexColumnGap(16) + .ColumnGap(16) .FlexAlignItems(LvtkAlignment::Start) .Padding({16,16,0,16}) ; @@ -117,7 +117,7 @@ LvtkElement::ptr IpsemLoremWideAndTall() container->Style() .FlexDirection(LvtkFlexDirection::Row) .FlexWrap(LvtkFlexWrap::NoWrap) - .FlexColumnGap(16) + .ColumnGap(16) .FlexAlignItems(LvtkAlignment::Start) .Padding({16,16,0,16}) ; @@ -158,7 +158,7 @@ LvtkElement::ptr ScrollBarTestPage::CreatePageView(LvtkTheme::ptr theme) .FlexAlignItems(LvtkAlignment::Start) .FlexDirection(LvtkFlexDirection::Row) .FlexWrap(LvtkFlexWrap::Wrap) - .FlexColumnGap(16) + .ColumnGap(16) .Background(theme->paper) .Padding({24, 16, 24, 16}) .VerticalAlignment(LvtkAlignment::Stretch) diff --git a/src/test/ScrollBarTestPage.hpp b/src/test/ScrollBarTestPage.hpp index 14627d5..92cac1c 100644 --- a/src/test/ScrollBarTestPage.hpp +++ b/src/test/ScrollBarTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/StandardDialogTestPage.cpp b/src/test/StandardDialogTestPage.cpp index 31c0d75..c58dab6 100644 --- a/src/test/StandardDialogTestPage.cpp +++ b/src/test/StandardDialogTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/StandardDialogTestPage.hpp b/src/test/StandardDialogTestPage.hpp index eb5316c..e58f393 100644 --- a/src/test/StandardDialogTestPage.hpp +++ b/src/test/StandardDialogTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/SvgTestPage.cpp b/src/test/SvgTestPage.cpp index 0cf9178..8a7242f 100644 --- a/src/test/SvgTestPage.cpp +++ b/src/test/SvgTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/SvgTestPage.hpp b/src/test/SvgTestPage.hpp index 9398d62..90afe40 100644 --- a/src/test/SvgTestPage.hpp +++ b/src/test/SvgTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/SyntaxTest.cpp b/src/test/SyntaxTest.cpp index 4999b44..cc14bfd 100644 --- a/src/test/SyntaxTest.cpp +++ b/src/test/SyntaxTest.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/TableTestPage.cpp b/src/test/TableTestPage.cpp new file mode 100644 index 0000000..06165c1 --- /dev/null +++ b/src/test/TableTestPage.cpp @@ -0,0 +1,301 @@ +// Copyright (c) 2023 Robin E. R. Davies +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#include "TableTestPage.hpp" +#include "lvtk/LvtkTableElement.hpp" +#include "lvtk/LvtkFlexGridElement.hpp" +#include "lvtk/LvtkDropdownElement.hpp" +#include "lvtk/LvtkVerticalStackElement.hpp" +#include "lvtk/LvtkBindingProperty.hpp" +#include "lvtk/LvtkNumericEditBoxElement.hpp" +#include "lvtk/LvtkTypographyElement.hpp" + +using namespace lvtk; + +constexpr size_t TABLE_ROWS = 5; + +static std::vector MakeTableChildren() +{ + std::vector result; + + auto style = LvtkStyle::Create(); + + for (size_t r = 0; r < TABLE_ROWS; ++r) + { + LvtkElement::ptr element; + + element = LvtkElement::Create(); + element->Style() + .Width(60 + ((r & 1) ? 20 : 0)) + .Height(20) + .Background(LvtkColor("#FF8080")); + result.push_back(element); + + element = LvtkElement::Create(); + element->Style() + .Width(60.0+ ((r % 3) * 20.0)) + .Height(20) + .Background(LvtkColor("#80FF80")); + result.push_back(element); + + element = LvtkElement::Create(); + element->Style() + .Width(60.0 + ((r % 4) *10.0)) + .Height(20) + .Background(LvtkColor("#8080FF")); + result.push_back(element); + + element = LvtkElement::Create(); + element->Style() + .HorizontalAlignment(LvtkAlignment::Stretch) + .Height(r == 0 ? 40 : 20) + .Background(LvtkColor("#804040")); + result.push_back(element); + + element = LvtkElement::Create(); + element->Style() + .HorizontalAlignment(LvtkAlignment::Stretch) + .Height(20.0 + ((r & 1) ? 30.0f : 0.0f)) + .Background(LvtkColor("#408040")); + result.push_back(element); + } + return result; +} + +template +class VariantDropdownElement : public LvtkDropdownElement +{ +public: + using self = VariantDropdownElement; + using super = LvtkDropdownElement; + using ptr = std::shared_ptr; + static ptr Create(const std::vector &items) + { + auto result = std::make_shared(); + result->DropdownItems(items); + return result; + } + VariantDropdownElement() + { + ValueProperty.SetElement(this, &VariantDropdownElement::OnValueChanged); + } + + BINDING_PROPERTY(Value, T, ((T)0)) +protected: + virtual void OnDropdownItemsChanged(const items_t &value) override + { + super::OnDropdownItemsChanged(value); + SelectedId(value[0].ItemId()); + } + + virtual void OnSelectedIdChanged(selection_id_t value) override + { + super::OnSelectedIdChanged(value); + Value((T)value); + } + virtual void OnValueChanged(T value) + { + SelectedId((selection_id_t)value); + } +}; + +#define V_DROPDOWN_ENTRY(VARIANT, MEMBER) \ + LvtkDropdownItem((int64_t)(VARIANT::MEMBER), (#MEMBER)) + +class TableTestElement : public LvtkContainerElement +{ +public: + using self = TableTestElement; + using super = LvtkContainerElement; + using ptr = std::shared_ptr; + static ptr Create() { return std::make_shared(); } + TableTestElement(); + +private: + LvtkTableElement::ptr MakeTable(); + LvtkTableElement::ptr table; + std::vector observerHandles; +}; + +#pragma GCC diagnostic ignored "-Wunused-function" +static LvtkElement::ptr LabeledControl(const std::string &label_, LvtkElement::ptr control) +{ + auto container = LvtkVerticalStackElement::Create(); + container->Style().HorizontalAlignment(LvtkAlignment::Start); + auto label = LvtkTypographyElement::Create(); + label->Text(label_); + label->Style().FontSize(11).Margin({6, 0, 0, 0}); + container->AddChild(label); + container->AddChild(control); + container->Style().Margin({4}); + return container; +} +static LvtkElement::ptr LabeledEditControl(const std::string &label_, LvtkElement::ptr control) +{ + auto container = LvtkVerticalStackElement::Create(); + container->Style().HorizontalAlignment(LvtkAlignment::Start); + auto label = LvtkTypographyElement::Create(); + label->Text(label_); + label->Style().FontSize(11).Margin({4, 0, 0, 8}); + container->AddChild(label); + container->AddChild(control); + container->Style().Margin({4}); + return container; +} +TableTestElement::TableTestElement() +{ + auto stack = LvtkVerticalStackElement::Create(); + + Style() + .HorizontalAlignment(LvtkAlignment::Stretch) + .VerticalAlignment(LvtkAlignment::Stretch) + ; + stack->Style() + .FlexDirection(LvtkFlexDirection::Column) + .FlexWrap(LvtkFlexWrap::NoWrap) + .HorizontalAlignment(LvtkAlignment::Stretch) + .VerticalAlignment(LvtkAlignment::Stretch); + { + { + auto element = LvtkElement::Create(); + element->Style() + .Width(LvtkMeasurement::Percent(100)) + .Height(1) + .Margin({0, 8, 0, 0}) + .Background(LvtkColor(0.3, 0.3, 0.3)); + stack->AddChild(element); + } + + + this->table = MakeTable(); + table->Style() + .Margin({0,16,0,16}) + ; + stack->AddChild(table); + + + auto controlGrid = LvtkFlexGridElement::Create(); + // { + // auto element = VariantDropdownElement::Create( + // { + // V_DROPDOWN_ENTRY(LvtkAlignment, Start), + // V_DROPDOWN_ENTRY(LvtkAlignment, End), + // V_DROPDOWN_ENTRY(LvtkAlignment, Center), + // }); + // this->observerHandles.push_back( + // element->ValueProperty.addObserver([this](LvtkAlignment value) + // { + // table->Style().FlexAlignItems(value); + // table->InvalidateLayout(); })); + // element->Style().Margin({8}); + // controlGrid->AddChild(LabeledControl("FlexAlignItems", element)); + // element->Value(LvtkAlignment::Start); + // } + { + auto element = LvtkNumericEditBoxElement::Create(); + element->ValueType(LvtkValueType::Int16) + .MinValue(0) + .MaxValue(20000); + element->Value(1); + element->Style().Width(100); + observerHandles.push_back( + element->ValueProperty.addObserver( + [this](double value) + { + table->Style().BorderWidth({value}); + table->InvalidateLayout(); + })); + controlGrid->AddChild(LabeledEditControl("Border Width", element)); + } + { + auto element = LvtkNumericEditBoxElement::Create(); + element->ValueType(LvtkValueType::Int16) + .MinValue(0) + .MaxValue(20000); + element->Style().Width(100); + element->Value(2); + observerHandles.push_back( + element->ValueProperty.addObserver( + [this](double value) + { + table->Style().CellPadding({value}); + table->InvalidateLayout(); + })); + controlGrid->AddChild(LabeledEditControl("Cell Padding", element)); + } + + stack->AddChild(controlGrid); + } + AddChild(stack); +} + +LvtkTableElement::ptr TableTestElement::MakeTable() +{ + + + auto element = LvtkTableElement::Create(); + auto &style = element->Style(); + style + .HorizontalAlignment(LvtkAlignment::Stretch) + .BorderWidth(1) + .BorderColor(LvtkColor("#808080")) + .CellPadding({2}) + ; + + std::vector tableChildren = MakeTableChildren(); + + element->Children(tableChildren); + element->ColumnDefinitions({ + {LvtkAlignment::Start, LvtkAlignment::Start, 150}, + {LvtkAlignment::Center, LvtkAlignment::Center, 0}, + {LvtkAlignment::End, LvtkAlignment::End, 0}, + {LvtkAlignment::Start, LvtkAlignment::Stretch, 2}, + {LvtkAlignment::End, LvtkAlignment::Stretch, 3}, + }); + + return element; +} + +LvtkElement::ptr TableTestPage::CreatePageView(LvtkTheme::ptr theme) +{ + + LvtkVerticalStackElement::ptr main = LvtkVerticalStackElement::Create(); + + main->Style() + .HorizontalAlignment(LvtkAlignment::Start) + .Background(theme->paper) + .Padding({16, 8, 16, 8}) + .VerticalAlignment(LvtkAlignment::Stretch) + .HorizontalAlignment(LvtkAlignment::Stretch); + + { + LvtkTypographyElement::ptr title = LvtkTypographyElement::Create(); + title->Variant(LvtkTypographyVariant::Title).Text("Table Test"); + + title->Style().Padding({0, 8, 0, 8}); + main->AddChild(title); + } + { + auto element = TableTestElement::Create(); + + main->AddChild(element); + } + + return main; +} diff --git a/src/test/TableTestPage.hpp b/src/test/TableTestPage.hpp new file mode 100644 index 0000000..74210e1 --- /dev/null +++ b/src/test/TableTestPage.hpp @@ -0,0 +1,39 @@ +// Copyright (c) 2023 Robin E. R. Davies +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#pragma once + +#include "TestPage.hpp" + +namespace lvtk { +class TableTestPage : public TestPage +{ +public: + using super = TestPage; + using ptr = std::shared_ptr; + static ptr Create() { return std::make_shared(); } + + TableTestPage() : TestPage("Table") + { + + } + LvtkElement::ptr CreatePageView(LvtkTheme::ptr theme) override; + +}; +} // namespace \ No newline at end of file diff --git a/src/test/TestPage.hpp b/src/test/TestPage.hpp index 4ee454b..de51ec6 100644 --- a/src/test/TestPage.hpp +++ b/src/test/TestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/TypographyTestPage.cpp b/src/test/TypographyTestPage.cpp index 8780efc..f884e9d 100644 --- a/src/test/TypographyTestPage.cpp +++ b/src/test/TypographyTestPage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/TypographyTestPage.hpp b/src/test/TypographyTestPage.hpp index 1ae1d02..893a8ed 100644 --- a/src/test/TypographyTestPage.hpp +++ b/src/test/TypographyTestPage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/VerticalStackTest.cpp b/src/test/VerticalStackTest.cpp index 41ba018..344f180 100644 --- a/src/test/VerticalStackTest.cpp +++ b/src/test/VerticalStackTest.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/VerticalStackTest.hpp b/src/test/VerticalStackTest.hpp index 58b5c4f..6d4733b 100644 --- a/src/test/VerticalStackTest.hpp +++ b/src/test/VerticalStackTest.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test/ss.hpp b/src/test/ss.hpp index 7436111..65a920f 100644 --- a/src/test/ss.hpp +++ b/src/test/ss.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test_plugin/CMakeLists.txt b/src/test_plugin/CMakeLists.txt index 0ef000e..1462f7b 100644 --- a/src/test_plugin/CMakeLists.txt +++ b/src/test_plugin/CMakeLists.txt @@ -44,6 +44,7 @@ add_custom_command( ) add_library(lv2tk_test SHARED + SamplePlugin.cpp SamplePlugin.hpp Lv2Plugin.cpp Lv2Plugin.hpp @@ -65,6 +66,8 @@ target_link_directories( ) add_library(lv2tk_test_ui SHARED + $ $ + SamplePluginUi.cpp ${CMAKE_CURRENT_BINARY_DIR}/SamplePluginInfo.hpp ) @@ -72,7 +75,8 @@ set_target_properties(lv2tk_test_ui PROPERTIES OUTPUT_NAME "${LV2_UI_SO_NAME}") set_target_properties(lv2tk_test_ui PROPERTIES PREFIX "") target_link_options(lv2tk_test_ui PRIVATE - "-Wl,-z,nodelete" + "-Wl,-z,nodelete" + -Wl,-uiLinkTarget ) diff --git a/src/test_plugin/Lv2Plugin.cpp b/src/test_plugin/Lv2Plugin.cpp index c083f2b..2618947 100644 --- a/src/test_plugin/Lv2Plugin.cpp +++ b/src/test_plugin/Lv2Plugin.cpp @@ -1,22 +1,22 @@ -// Copyright (c) 2023 Robin Davies -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +// Copyright (c) 2023 Robin E. R. Davies +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + #include "Lv2Plugin.hpp" diff --git a/src/test_plugin/Lv2Plugin.hpp b/src/test_plugin/Lv2Plugin.hpp index acb21de..42a16b7 100644 --- a/src/test_plugin/Lv2Plugin.hpp +++ b/src/test_plugin/Lv2Plugin.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test_plugin/SamplePlugin.cpp b/src/test_plugin/SamplePlugin.cpp index 205398e..af37a34 100644 --- a/src/test_plugin/SamplePlugin.cpp +++ b/src/test_plugin/SamplePlugin.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test_plugin/SamplePlugin.hpp b/src/test_plugin/SamplePlugin.hpp index 0839e7f..427e5ce 100644 --- a/src/test_plugin/SamplePlugin.hpp +++ b/src/test_plugin/SamplePlugin.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/src/test_plugin/SamplePluginUi.cpp b/src/test_plugin/SamplePluginUi.cpp index d93e840..882c4a5 100644 --- a/src/test_plugin/SamplePluginUi.cpp +++ b/src/test_plugin/SamplePluginUi.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Robin Davies +// Copyright (c) 2023 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -41,6 +41,8 @@ SamplePlugin::SamplePlugin() : super( this->Theme(theme); } +// Refereence this variable to get the linker to deman-link the entire .obj. +int uiLinkTarget; static Lv2UIRegistration registration { PLUGIN_UI_URI};