From f79805402bf8bd9b7ceb4561d4c089411fb5927f Mon Sep 17 00:00:00 2001 From: Daekwang Ryu Date: Thu, 30 Mar 2023 13:14:03 +0900 Subject: [PATCH] Add Window::SetLayout method The new `SetLayout` method allows users to easily snap windows to specific positions and sizes. This feature is similar to the snap window feature found in many operating systems, allowing users to quickly arrange their windows in a convenient and efficient manner. Change-Id: I71fe381220ef455bc60531b15500ebb03fa15671 --- automated-tests/src/dali-adaptor/utc-Dali-Window.cpp | 16 ++++++++++++++++ .../window-system/android/window-base-android.cpp | 4 ++++ .../internal/window-system/android/window-base-android.h | 5 +++++ dali/internal/window-system/common/window-base.h | 5 +++++ dali/internal/window-system/common/window-impl.cpp | 5 +++++ dali/internal/window-system/common/window-impl.h | 5 +++++ dali/internal/window-system/macos/window-base-mac.h | 5 +++++ dali/internal/window-system/macos/window-base-mac.mm | 4 ++++ .../tizen-wayland/ecore-wl/window-base-ecore-wl.cpp | 4 ++++ .../tizen-wayland/ecore-wl/window-base-ecore-wl.h | 5 +++++ .../tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp | 6 ++++++ .../tizen-wayland/ecore-wl2/window-base-ecore-wl2.h | 5 +++++ .../window-system/ubuntu-x11/window-base-ecore-x.cpp | 4 ++++ .../window-system/ubuntu-x11/window-base-ecore-x.h | 5 +++++ dali/internal/window-system/windows/window-base-win.cpp | 4 ++++ dali/internal/window-system/windows/window-base-win.h | 5 +++++ dali/internal/window-system/x11/window-base-x.cpp | 4 ++++ dali/internal/window-system/x11/window-base-x.h | 5 +++++ dali/public-api/adaptor-framework/window.cpp | 5 +++++ dali/public-api/adaptor-framework/window.h | 16 ++++++++++++++++ 20 files changed, 117 insertions(+) diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp index 2cab8de..19100ce 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp @@ -943,6 +943,22 @@ int UtcDaliWindowGetPositionNegative(void) END_TEST; } +int UtcDaliWindowSetLayoutNegative(void) +{ + Dali::Window instance; + try + { + unsigned int arg1(0); + instance.SetLayout(arg1, arg1, arg1, arg1, arg1, arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + int UtcDaliWindowGetRootLayerNegative(void) { Dali::Window instance; diff --git a/dali/internal/window-system/android/window-base-android.cpp b/dali/internal/window-system/android/window-base-android.cpp index abab78f..8a83136 100644 --- a/dali/internal/window-system/android/window-base-android.cpp +++ b/dali/internal/window-system/android/window-base-android.cpp @@ -176,6 +176,10 @@ void WindowBaseAndroid::MoveResize(PositionSize positionSize) { } +void WindowBaseAndroid::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) +{ +} + void WindowBaseAndroid::SetClass(const std::string& name, const std::string& className) { } diff --git a/dali/internal/window-system/android/window-base-android.h b/dali/internal/window-system/android/window-base-android.h index 6be667e..1f6463d 100644 --- a/dali/internal/window-system/android/window-base-android.h +++ b/dali/internal/window-system/android/window-base-android.h @@ -178,6 +178,11 @@ public: */ void MoveResize(PositionSize positionSize) override; + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout() + */ + void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override; + /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass() */ diff --git a/dali/internal/window-system/common/window-base.h b/dali/internal/window-system/common/window-base.h index f5fc81d..3a1784d 100644 --- a/dali/internal/window-system/common/window-base.h +++ b/dali/internal/window-system/common/window-base.h @@ -167,6 +167,11 @@ public: virtual void MoveResize(Dali::PositionSize positionSize) = 0; /** + * @copydoc Dali::Window::SetLayout() + */ + virtual void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) = 0; + + /** * @copydoc Dali::Window::SetClass() */ virtual void SetClass(const std::string& name, const std::string& className) = 0; diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index 98f3dbd..a309df3 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -815,6 +815,11 @@ void Window::SetPositionSize(PositionSize positionSize) Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height)); } +void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) +{ + mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan); +} + Dali::Layer Window::GetRootLayer() const { return mScene.GetRootLayer(); diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index b456245..d0d6866 100644 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -332,6 +332,11 @@ public: PositionSize GetPositionSize() const; /** + * @copydoc Dali::Window::SetLayout() + */ + void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan); + + /** * @copydoc Dali::Window::GetRootLayer() */ Dali::Layer GetRootLayer() const; diff --git a/dali/internal/window-system/macos/window-base-mac.h b/dali/internal/window-system/macos/window-base-mac.h index 174c6bc..4d3f047 100644 --- a/dali/internal/window-system/macos/window-base-mac.h +++ b/dali/internal/window-system/macos/window-base-mac.h @@ -107,6 +107,11 @@ public: */ void MoveResize(PositionSize positionSize) override; + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout() + */ + void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override; + /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass() */ diff --git a/dali/internal/window-system/macos/window-base-mac.mm b/dali/internal/window-system/macos/window-base-mac.mm index 988ea87..16d2f75 100644 --- a/dali/internal/window-system/macos/window-base-mac.mm +++ b/dali/internal/window-system/macos/window-base-mac.mm @@ -456,6 +456,10 @@ void WindowBaseCocoa::MoveResize( PositionSize positionSize ) [mImpl->mWindow.contentView setFrameSize:size]; } +void WindowBaseCocoa::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) +{ +} + void WindowBaseCocoa::SetClass( const std::string& name, const std::string& className ) { } diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp index e13f885..fb8bf7f 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp @@ -1312,6 +1312,10 @@ void WindowBaseEcoreWl::MoveResize(PositionSize positionSize) ecore_wl_window_update_size(mEcoreWindow, positionSize.width, positionSize.height); } +void WindowBaseEcoreWl::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) +{ +} + void WindowBaseEcoreWl::SetClass(const std::string& name, const std::string& className) { ecore_wl_window_title_set(mEcoreWindow, name.c_str()); diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h index 463359c..94ad113 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h +++ b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h @@ -234,6 +234,11 @@ public: */ void MoveResize(PositionSize positionSize) override; + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout() + */ + void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override; + /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass() */ diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp index 34fb15c..f7993df 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp @@ -1838,6 +1838,12 @@ void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize) ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height); } +void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) +{ + DALI_LOG_RELEASE_INFO("ecore_wl2_window_layout_set, numCols[%d], numRows[%d], column[%d], row[%d], colSpan[%d], rowSpan[%d]\n", numCols, numRows, column, row, colSpan, rowSpan); + ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan); +} + void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className) { ecore_wl2_window_title_set(mEcoreWindow, name.c_str()); diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h index d5789ed..00ca5bd 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h @@ -273,6 +273,11 @@ public: */ void MoveResize(PositionSize positionSize) override; + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout() + */ + void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override; + /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass() */ diff --git a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp index c70bc4b..39bcf9a 100644 --- a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp +++ b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp @@ -707,6 +707,10 @@ void WindowBaseEcoreX::MoveResize(PositionSize positionSize) ecore_x_window_move_resize(mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height); } +void WindowBaseEcoreX::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) +{ +} + void WindowBaseEcoreX::SetClass(const std::string& name, const std::string& className) { ecore_x_icccm_title_set(mEcoreWindow, name.c_str()); diff --git a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h index 054aa9c..d2a2b81 100644 --- a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h +++ b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h @@ -185,6 +185,11 @@ public: void MoveResize(PositionSize positionSize) override; /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout() + */ + void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override; + + /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass() */ void SetClass(const std::string& name, const std::string& className) override; diff --git a/dali/internal/window-system/windows/window-base-win.cpp b/dali/internal/window-system/windows/window-base-win.cpp index 22aa274..c8792be 100644 --- a/dali/internal/window-system/windows/window-base-win.cpp +++ b/dali/internal/window-system/windows/window-base-win.cpp @@ -298,6 +298,10 @@ void WindowBaseWin::MoveResize(PositionSize positionSize) { } +void WindowBaseWin::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) +{ +} + void WindowBaseWin::SetClass(const std::string& name, const std::string& className) { } diff --git a/dali/internal/window-system/windows/window-base-win.h b/dali/internal/window-system/windows/window-base-win.h index 748157a..90c8d21 100644 --- a/dali/internal/window-system/windows/window-base-win.h +++ b/dali/internal/window-system/windows/window-base-win.h @@ -167,6 +167,11 @@ public: void MoveResize(PositionSize positionSize) override; /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout() + */ + void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override; + + /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass() */ void SetClass(const std::string& name, const std::string& className) override; diff --git a/dali/internal/window-system/x11/window-base-x.cpp b/dali/internal/window-system/x11/window-base-x.cpp index be48605..c6868ce 100644 --- a/dali/internal/window-system/x11/window-base-x.cpp +++ b/dali/internal/window-system/x11/window-base-x.cpp @@ -658,6 +658,10 @@ void WindowBaseX::MoveResize(PositionSize positionSize) WindowSystem::GetImplementation().MoveResize(mWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height); } +void WindowBaseX::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) +{ +} + void WindowBaseX::SetClass(const std::string& name, const std::string& className) { WindowSystem::GetImplementation().SetClass(mWindow, name, className); diff --git a/dali/internal/window-system/x11/window-base-x.h b/dali/internal/window-system/x11/window-base-x.h index a3bd1f1..c801f4c 100644 --- a/dali/internal/window-system/x11/window-base-x.h +++ b/dali/internal/window-system/x11/window-base-x.h @@ -188,6 +188,11 @@ public: */ void MoveResize(PositionSize positionSize) override; + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout() + */ + void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override; + /** * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass() */ diff --git a/dali/public-api/adaptor-framework/window.cpp b/dali/public-api/adaptor-framework/window.cpp index ae9192d..4e834a6 100644 --- a/dali/public-api/adaptor-framework/window.cpp +++ b/dali/public-api/adaptor-framework/window.cpp @@ -323,6 +323,11 @@ Dali::Window::WindowPosition Window::GetPosition() const return GetImplementation(*this).GetPosition(); } +void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) +{ + return GetImplementation(*this).SetLayout(numCols, numRows, column, row, colSpan, rowSpan); +} + void Window::SetTransparency(bool transparent) { GetImplementation(*this).SetTransparency(transparent); diff --git a/dali/public-api/adaptor-framework/window.h b/dali/public-api/adaptor-framework/window.h index fc12a6e..1d1f8a8 100644 --- a/dali/public-api/adaptor-framework/window.h +++ b/dali/public-api/adaptor-framework/window.h @@ -549,6 +549,22 @@ public: WindowPosition GetPosition() const; /** + * @brief Sets the layout of the window. + * + * This method sets the layout of the window based on the specified number of columns and rows, + * as well as the position and size of the window within that layout. + * + * @param numCols The number of columns in the layout. + * @param numRows The number of rows in the layout. + * @param column The column number of the window within the layout. + * @param row The row number of the window within the layout. + * @param colSpan The number of columns the window should span within the layout. + * @param rowSpan The number of rows the window should span within the layout. + * @SINCE_2_2.20 + */ + void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan); + + /** * @brief Sets whether the window is transparent or not. * * @SINCE_1_2.60 -- 2.7.4