Commit 26d90f461f65ded73b9c4bcb30bef5b1f7b550cf
Committed by
Gerrit Code Review
Merge "Add window example" into devel/master
Showing
6 changed files
with
597 additions
and
0 deletions
com.samsung.dali-demo.xml
| @@ -397,6 +397,9 @@ | @@ -397,6 +397,9 @@ | ||
| 397 | <ui-application appid="web-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/web-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | 397 | <ui-application appid="web-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/web-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 398 | <label>Web View</label> | 398 | <label>Web View</label> |
| 399 | </ui-application> | 399 | </ui-application> |
| 400 | + <ui-application appid="window.example" exec="/usr/apps/com.samsung.dali-demo/bin/window.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | ||
| 401 | + <label>Window</label> | ||
| 402 | + </ui-application> | ||
| 400 | <ui-application appid="waves.example" exec="/usr/apps/com.samsung.dali-demo/bin/waves.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | 403 | <ui-application appid="waves.example" exec="/usr/apps/com.samsung.dali-demo/bin/waves.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 401 | <label>Waves</label> | 404 | <label>Waves</label> |
| 402 | </ui-application> | 405 | </ui-application> |
examples-reel/dali-examples-reel.cpp
| @@ -111,6 +111,7 @@ int DALI_EXPORT_API main(int argc, char** argv) | @@ -111,6 +111,7 @@ int DALI_EXPORT_API main(int argc, char** argv) | ||
| 111 | demo.AddExample(Example("tooltip.example", DALI_DEMO_STR_TITLE_TOOLTIP)); | 111 | demo.AddExample(Example("tooltip.example", DALI_DEMO_STR_TITLE_TOOLTIP)); |
| 112 | demo.AddExample(Example("transitions.example", DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS)); | 112 | demo.AddExample(Example("transitions.example", DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS)); |
| 113 | demo.AddExample(Example("web-view.example", DALI_DEMO_STR_TITLE_WEB_VIEW)); | 113 | demo.AddExample(Example("web-view.example", DALI_DEMO_STR_TITLE_WEB_VIEW)); |
| 114 | + demo.AddExample(Example("window.example", DALI_DEMO_STR_TITLE_WINDOW)); | ||
| 114 | 115 | ||
| 115 | demo.SortAlphabetically(true); | 116 | demo.SortAlphabetically(true); |
| 116 | 117 |
examples/window/window-example.cpp
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright (c) 2019 Samsung Electronics Co., Ltd. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + * | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 19 | +#include <dali/integration-api/scene.h> | ||
| 20 | +#include <dali/devel-api/adaptor-framework/window-devel.h> | ||
| 21 | +#include <dali/integration-api/debug.h> | ||
| 22 | + | ||
| 23 | +using namespace Dali; | ||
| 24 | +using namespace Dali::Toolkit; | ||
| 25 | + | ||
| 26 | +const int MARGIN = 50; | ||
| 27 | +static int count = 0; | ||
| 28 | + | ||
| 29 | +// This example shows how to create and display Hello World! using a simple TextActor | ||
| 30 | +// | ||
| 31 | +class WindowExampleController : public ConnectionTracker | ||
| 32 | +{ | ||
| 33 | +public: | ||
| 34 | + WindowExampleController(Application &application) | ||
| 35 | + : mApplication(application), | ||
| 36 | + manual_rotation_flag(false), | ||
| 37 | + rotation_count(0), | ||
| 38 | + rot(0), | ||
| 39 | + bColor(0) | ||
| 40 | + { | ||
| 41 | + // Connect to the Application's Init signal | ||
| 42 | + mApplication.InitSignal().Connect(this, &WindowExampleController::Create); | ||
| 43 | + mApplication.PauseSignal().Connect(this, &WindowExampleController::Pause); | ||
| 44 | + mApplication.ResumeSignal().Connect(this, &WindowExampleController::Resume); | ||
| 45 | + mApplication.DeviceOrientationChangedSignal().Connect(this, &WindowExampleController::OnDeviceOrientationChanged); | ||
| 46 | + mApplication.LowMemorySignal().Connect(this, &WindowExampleController::OnLowMemory); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + ~WindowExampleController() = default; | ||
| 50 | + | ||
| 51 | + // The Init signal is received once (only) during the Application lifetime | ||
| 52 | + void Create(Application &application) | ||
| 53 | + { | ||
| 54 | + // Get a handle to the window and set the background colour | ||
| 55 | + Window window = application.GetWindow(); | ||
| 56 | + window.AddAuxiliaryHint("wm.policy.win.user.geometry", "1"); | ||
| 57 | + window.SetBackgroundColor(Color::WHITE); | ||
| 58 | + window.SetTransparency(false); | ||
| 59 | + | ||
| 60 | + window.SetType(WindowType::NOTIFICATION); | ||
| 61 | + window.SetNotificationLevel(WindowNotificationLevel::MEDIUM); | ||
| 62 | + | ||
| 63 | + currentOrientation = Dali::WindowOrientation::PORTRAIT; | ||
| 64 | + enableTimer = false; | ||
| 65 | + bChangedOrientation = false; | ||
| 66 | + manual_rotation_flag = false; | ||
| 67 | + | ||
| 68 | + // Add a text label to the window | ||
| 69 | + TextLabel textLabel = TextLabel::New("Window Example"); | ||
| 70 | + textLabel.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); | ||
| 71 | + textLabel.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); | ||
| 72 | + textLabel.SetProperty(Actor::Property::NAME, "WindowExampleLabel"); | ||
| 73 | + textLabel.SetBackgroundColor(Color::RED); | ||
| 74 | + window.Add(textLabel); | ||
| 75 | + | ||
| 76 | + // Create a clipping control and add a child to it | ||
| 77 | + mClipControl = Control::New(); | ||
| 78 | + mClipControl.SetProperty(Actor::Property::SIZE, Vector2(250.0f, 100.0f)); | ||
| 79 | + mClipControl.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.75f, 0.75f, 0.5f)); | ||
| 80 | + mClipControl.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); | ||
| 81 | + mClipControl.SetBackgroundColor(Color::BLUE); | ||
| 82 | + window.Add(mClipControl); | ||
| 83 | + | ||
| 84 | + auto child = Control::New(); | ||
| 85 | + child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 250.0f)); | ||
| 86 | + child.SetProperty(Actor::Property::PARENT_ORIGIN, AnchorPoint::CENTER); | ||
| 87 | + child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); | ||
| 88 | + child.SetBackgroundColor(Color::GREEN); | ||
| 89 | + mClipControl.Add(child); | ||
| 90 | + | ||
| 91 | + // Respond to key events | ||
| 92 | + window.KeyEventSignal().Connect(this, &WindowExampleController::OnKeyEvent); | ||
| 93 | + | ||
| 94 | + // Respond to a click anywhere on the window | ||
| 95 | + window.GetRootLayer().TouchedSignal().Connect(this, &WindowExampleController::OnTouch); | ||
| 96 | + window.ResizeSignal().Connect(this, &WindowExampleController::OnWindowResized); | ||
| 97 | + DevelWindow::MovedSignal(window).Connect(this, &WindowExampleController::OnWindowMoved); | ||
| 98 | + DevelWindow::OrientationChangedSignal(window).Connect(this, &WindowExampleController::OnWindowOrientationChanged); | ||
| 99 | + DevelWindow::MoveCompletedSignal(window).Connect(this, &WindowExampleController::OnWindowMovedByServer); | ||
| 100 | + DevelWindow::ResizeCompletedSignal(window).Connect(this, &WindowExampleController::OnWindowResizedByServer); | ||
| 101 | + | ||
| 102 | + | ||
| 103 | + window.AddAvailableOrientation(Dali::WindowOrientation::PORTRAIT); | ||
| 104 | + window.AddAvailableOrientation(Dali::WindowOrientation::LANDSCAPE); | ||
| 105 | + window.AddAvailableOrientation(Dali::WindowOrientation::PORTRAIT_INVERSE); | ||
| 106 | + window.AddAvailableOrientation(Dali::WindowOrientation::LANDSCAPE_INVERSE); | ||
| 107 | + | ||
| 108 | + window.Show(); | ||
| 109 | + | ||
| 110 | + mTimer = Timer::New(50); | ||
| 111 | + mTimer.TickSignal().Connect(this, &WindowExampleController::OnTimerTick); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + void Pause(Application &application) | ||
| 115 | + { | ||
| 116 | + DALI_LOG_RELEASE_INFO("Application is paused..***********************\n"); | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + void Resume(Application &application) | ||
| 120 | + { | ||
| 121 | + DALI_LOG_RELEASE_INFO("Application is resumed..***********************\n"); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + void PresentedCallback( int frameId ) | ||
| 125 | + { | ||
| 126 | + DALI_LOG_RELEASE_INFO("PresentedCallback: FrameId %d\n",frameId); | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + void OnDeviceOrientationChanged(DeviceStatus::Orientation::Status status) | ||
| 130 | + { | ||
| 131 | + DALI_LOG_RELEASE_INFO("orientation status: %d\n",status); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + void OnLowMemory(DeviceStatus::Memory::Status status) | ||
| 135 | + { | ||
| 136 | + DALI_LOG_RELEASE_INFO("low memory status: %d\n",status); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + bool OnTimerTick() | ||
| 140 | + { | ||
| 141 | + Dali::Window window = mApplication.GetWindow(); | ||
| 142 | + bool ret = true; | ||
| 143 | + | ||
| 144 | + if (DevelWindow::IsWindowRotating(window) == true) | ||
| 145 | + { | ||
| 146 | + isRotating = true; | ||
| 147 | + DALI_LOG_RELEASE_INFO("Window is rotating!!!!\n"); | ||
| 148 | + count++; | ||
| 149 | + if(count > 100) | ||
| 150 | + { | ||
| 151 | + DALI_LOG_RELEASE_INFO("Send AckWindowRotation in Timer\n"); | ||
| 152 | + DevelWindow::SendRotationCompletedAcknowledgement(window); | ||
| 153 | + count = 0; | ||
| 154 | + ret = false; | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + else | ||
| 158 | + { | ||
| 159 | + DALI_LOG_RELEASE_INFO("Window is not rotating!!!!\n"); | ||
| 160 | + } | ||
| 161 | + return ret; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + void OnWindowMoved(Dali::Window winHandle, Dali::Window::WindowPosition position) | ||
| 165 | + { | ||
| 166 | + DALI_LOG_RELEASE_INFO("OnWindowMoved, x:%d, y:%d, width:%d\n", position.GetX(), position.GetY()); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + void OnWindowMovedByServer(Dali::Window winHandle, Dali::Window::WindowPosition position) | ||
| 170 | + { | ||
| 171 | + DALI_LOG_RELEASE_INFO("OnWindowMovedByServer, x:%d, y:%d, width:%d\n", position.GetX(), position.GetY()); | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + void OnWindowResizedByServer(Dali::Window winHandle, Dali::Window::WindowSize size) | ||
| 175 | + { | ||
| 176 | + DALI_LOG_RELEASE_INFO("OnWindowResizedByServer, x:%d, y:%d, width:%d\n", size.GetWidth(), size.GetHeight()); | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + void OnWindowOrientationChanged(Dali::Window window, Dali::WindowOrientation orientation) | ||
| 180 | + { | ||
| 181 | + DALI_LOG_RELEASE_INFO("OnWindowOrientationChanged, changed window orientation: %d\n", orientation); | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + void OnWindowResized(Dali::Window winHandle, Dali::Window::WindowSize size) | ||
| 185 | + { | ||
| 186 | + DALI_LOG_RELEASE_INFO("Resize finish %d x heigt %d\n", size.GetWidth(), size.GetHeight()); | ||
| 187 | + if(bChangedOrientation) | ||
| 188 | + { | ||
| 189 | + if( DevelWindow::GetCurrentOrientation(winHandle) == Dali::WindowOrientation::PORTRAIT) | ||
| 190 | + { | ||
| 191 | + DALI_LOG_RELEASE_INFO("DevelWindow::OnWindowResized, current orientation is Dali::WindowOrientation::PORTRAIT\n"); | ||
| 192 | + PositionSize newWindowPosition(0, 0, 400, 300); | ||
| 193 | + DALI_LOG_RELEASE_INFO("DevelWindow::OnWindowResized, SetPositionSize(720 * 1280)\n"); | ||
| 194 | + DevelWindow::SetPositionSize(winHandle, newWindowPosition); | ||
| 195 | + } | ||
| 196 | + else if( DevelWindow::GetCurrentOrientation(winHandle) == Dali::WindowOrientation::LANDSCAPE) | ||
| 197 | + { | ||
| 198 | + DALI_LOG_RELEASE_INFO("DevelWindow::OnWindowResized, current orientation is Dali::WindowOrientation::LANDSCAPE\n"); | ||
| 199 | + PositionSize newWindowPosition(0, 0, 1280, 720); | ||
| 200 | + DALI_LOG_RELEASE_INFO("DevelWindow::OnWindowResized, SetPositionSize(1280 * 720)\n"); | ||
| 201 | + DevelWindow::SetPositionSize(winHandle, newWindowPosition); | ||
| 202 | + } | ||
| 203 | + else if( DevelWindow::GetCurrentOrientation(winHandle) == Dali::WindowOrientation::PORTRAIT_INVERSE) | ||
| 204 | + { | ||
| 205 | + DALI_LOG_RELEASE_INFO("DevelWindow::OnWindowResized, current orientation is Dali::WindowOrientation::PORTRAIT_INVERSE\n"); | ||
| 206 | + PositionSize newWindowPosition(100, 100, 720, 1280); | ||
| 207 | + DALI_LOG_RELEASE_INFO("DevelWindow::OnWindowResized, SetPositionSize(100, 100, 720 * 1280)\n"); | ||
| 208 | + DevelWindow::SetPositionSize(winHandle, newWindowPosition); | ||
| 209 | + } | ||
| 210 | + else if( DevelWindow::GetCurrentOrientation(winHandle) == Dali::WindowOrientation::LANDSCAPE_INVERSE) | ||
| 211 | + { | ||
| 212 | + DALI_LOG_RELEASE_INFO("DevelWindow::OnWindowResized, current orientation is Dali::WindowOrientation::LANDSCAPE_INVERSE\n"); | ||
| 213 | + PositionSize newWindowPosition(100, 100, 1280, 720); | ||
| 214 | + DALI_LOG_RELEASE_INFO("DevelWindow::OnWindowResized, SetPositionSize(100, 100, 1280 * 720)\n"); | ||
| 215 | + DevelWindow::SetPositionSize(winHandle, newWindowPosition); | ||
| 216 | + } | ||
| 217 | + } | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + bool OnTouch(Actor actor, const TouchEvent &touch) | ||
| 221 | + { | ||
| 222 | + if (touch.GetState(0) == PointState::DOWN) | ||
| 223 | + { | ||
| 224 | + const int local_x = static_cast<int>(touch.GetLocalPosition(0).x); | ||
| 225 | + const int local_y = static_cast<int>(touch.GetLocalPosition(0).y); | ||
| 226 | + const int global_x = static_cast<int>(touch.GetScreenPosition(0).x); | ||
| 227 | + const int global_y = static_cast<int>(touch.GetScreenPosition(0).y); | ||
| 228 | + | ||
| 229 | + DALI_LOG_RELEASE_INFO("Main Window Touch Event : x:%d, y:%d\n", local_x, local_y); | ||
| 230 | + DALI_LOG_RELEASE_INFO("global position: x:%d, y:%d\n", global_x, global_y); | ||
| 231 | + | ||
| 232 | + Dali::Window window = mApplication.GetWindow(); | ||
| 233 | + Window::WindowSize windowSize = window.GetSize(); | ||
| 234 | + | ||
| 235 | + DALI_LOG_RELEASE_INFO("window size: w:%d, h:%d\n", windowSize.GetWidth(), windowSize.GetHeight()); | ||
| 236 | + DevelWindow::EnableFloatingMode(window, true); | ||
| 237 | + | ||
| 238 | + if ((local_x < MARGIN) && (local_y < MARGIN)) // left top corner | ||
| 239 | + { | ||
| 240 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: TOP_LEFT\n", local_x, local_y); | ||
| 241 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::TOP_LEFT); | ||
| 242 | + } | ||
| 243 | + else if ((local_x > (windowSize.GetWidth() - MARGIN)) && (local_y < MARGIN)) // rigth top corner | ||
| 244 | + { | ||
| 245 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: TOP_RIGHT\n", local_x, local_y); | ||
| 246 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::TOP_RIGHT); | ||
| 247 | + } | ||
| 248 | + else if ((local_x > MARGIN) && (local_x < (windowSize.GetWidth() - MARGIN)) && (local_y < MARGIN)) | ||
| 249 | + { | ||
| 250 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: TOP\n", local_x, local_y); | ||
| 251 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::TOP); | ||
| 252 | + } | ||
| 253 | + else if ((local_x < MARGIN) && (local_y < (windowSize.GetHeight() - MARGIN)) && (local_y > MARGIN)) | ||
| 254 | + { | ||
| 255 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: TOP\n", local_x, local_y); | ||
| 256 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::LEFT); | ||
| 257 | + } | ||
| 258 | + else if ((local_x > (windowSize.GetWidth() - MARGIN)) && (local_y < (windowSize.GetHeight() - MARGIN)) && (local_y > MARGIN)) | ||
| 259 | + { | ||
| 260 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: LEFT\n", local_x, local_y); | ||
| 261 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::RIGHT); | ||
| 262 | + } | ||
| 263 | + else if ((local_x < MARGIN) && (local_y > (windowSize.GetHeight() - MARGIN))) // left bottom corner | ||
| 264 | + { | ||
| 265 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: RIGHT\n", local_x, local_y); | ||
| 266 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::BOTTOM_LEFT); | ||
| 267 | + } | ||
| 268 | + else if ((local_x > (windowSize.GetWidth() - MARGIN)) && (local_y > (windowSize.GetHeight() - MARGIN))) // right bottom corner | ||
| 269 | + { | ||
| 270 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: BOTTOM_RIGHT\n", local_x, local_y); | ||
| 271 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::BOTTOM_RIGHT); | ||
| 272 | + } | ||
| 273 | + else | ||
| 274 | + { | ||
| 275 | + DALI_LOG_RELEASE_INFO("RequestMoveToServer\n", local_x, local_y); | ||
| 276 | + DevelWindow::RequestMoveToServer(window); | ||
| 277 | + } | ||
| 278 | + } | ||
| 279 | + return true; | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + ////////////////////////////////////////////////////////////////////////// | ||
| 283 | + // Test Sub Window Resize | ||
| 284 | + | ||
| 285 | + void CreateSubWindow() | ||
| 286 | + { | ||
| 287 | + mSecondWindow = Window::New(PositionSize(0, 0, 600, 400), "", false); | ||
| 288 | + mSecondWindow.SetTransparency(true); | ||
| 289 | + mSecondWindow.SetBackgroundColor(Vector4(1.0, 0.3, 0.3, 0.5)); | ||
| 290 | + | ||
| 291 | + mTextLabel2 = TextLabel::New( "Second window" ); | ||
| 292 | + mTextLabel2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); | ||
| 293 | + mTextLabel2.SetProperty( Actor::Property::NAME, "Second Window"); | ||
| 294 | + mSecondWindow.Add( mTextLabel2 ); | ||
| 295 | + | ||
| 296 | + mSecondWindow.GetRootLayer().TouchedSignal().Connect(this, &WindowExampleController::OnSubWindowTouch); | ||
| 297 | + mSecondWindow.ResizeSignal().Connect(this, &WindowExampleController::OnSubWindowResized); | ||
| 298 | + DevelWindow::MovedSignal(mSecondWindow).Connect(this, &WindowExampleController::OnSubWindowMoved); | ||
| 299 | + DevelWindow::MoveCompletedSignal(mSecondWindow).Connect(this, &WindowExampleController::OnSubWindowMovedByServer); | ||
| 300 | + DevelWindow::ResizeCompletedSignal(mSecondWindow).Connect(this, &WindowExampleController::OnSubWindowResizedByServer); | ||
| 301 | + | ||
| 302 | + mSecondWindow.AddAvailableOrientation( Dali::WindowOrientation::PORTRAIT ); | ||
| 303 | + mSecondWindow.AddAvailableOrientation( Dali::WindowOrientation::LANDSCAPE ); | ||
| 304 | + mSecondWindow.AddAvailableOrientation( Dali::WindowOrientation::PORTRAIT_INVERSE ); | ||
| 305 | + mSecondWindow.AddAvailableOrientation( Dali::WindowOrientation::LANDSCAPE_INVERSE ); | ||
| 306 | + mSecondWindow.Show(); | ||
| 307 | + | ||
| 308 | + Rect<int> setInputRegion(0, 0, 1920, 1080); | ||
| 309 | + //mSecondWindow.SetInputRegion(setInputRegion); | ||
| 310 | + DevelWindow::ExcludeInputRegion(mSecondWindow, setInputRegion); | ||
| 311 | + | ||
| 312 | + Dali::Window window = mApplication.GetWindow(); | ||
| 313 | + DevelWindow::SetParent(mSecondWindow, window); | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | + void OnSubWindowMoved(Dali::Window winHandle, Dali::Window::WindowPosition position) | ||
| 317 | + { | ||
| 318 | + DALI_LOG_RELEASE_INFO("OnWindowMoved, x:%d, y:%d, width:%d\n", position.GetX(), position.GetY()); | ||
| 319 | + } | ||
| 320 | + | ||
| 321 | + void OnSubWindowResized(Dali::Window winHandle, Dali::Window::WindowSize size) | ||
| 322 | + { | ||
| 323 | + DALI_LOG_RELEASE_INFO("OnSubWindowResized %d x heigt %d\n", size.GetWidth(), size.GetHeight()); | ||
| 324 | + } | ||
| 325 | + | ||
| 326 | + void OnSubWindowMovedByServer(Dali::Window winHandle, Dali::Window::WindowPosition position) | ||
| 327 | + { | ||
| 328 | + DALI_LOG_RELEASE_INFO("OnWindowMovedByServer, x:%d, y:%d, width:%d\n", position.GetX(), position.GetY()); | ||
| 329 | + } | ||
| 330 | + | ||
| 331 | + void OnSubWindowResizedByServer(Dali::Window winHandle, Dali::Window::WindowSize size) | ||
| 332 | + { | ||
| 333 | + DALI_LOG_RELEASE_INFO("OnWindowResizedByServer, x:%d, y:%d, width:%d\n", size.GetWidth(), size.GetHeight()); | ||
| 334 | + } | ||
| 335 | + | ||
| 336 | + bool OnSubWindowTouch(Actor actor, const TouchEvent &touch) | ||
| 337 | + { | ||
| 338 | + if (touch.GetState(0) == PointState::DOWN) | ||
| 339 | + { | ||
| 340 | + const int local_x = static_cast<int>(touch.GetLocalPosition(0).x); | ||
| 341 | + const int local_y = static_cast<int>(touch.GetLocalPosition(0).y); | ||
| 342 | + const int global_x = static_cast<int>(touch.GetScreenPosition(0).x); | ||
| 343 | + const int global_y = static_cast<int>(touch.GetScreenPosition(0).y); | ||
| 344 | + | ||
| 345 | + DALI_LOG_RELEASE_INFO("SubWindow Touch Event : x:%d, y:%d\n", local_x, local_y); | ||
| 346 | + DALI_LOG_RELEASE_INFO("global position: x:%d, y:%d\n", global_x, global_y); | ||
| 347 | + | ||
| 348 | + Dali::Window window = mSecondWindow; | ||
| 349 | + Window::WindowSize windowSize = window.GetSize(); | ||
| 350 | + | ||
| 351 | + DALI_LOG_RELEASE_INFO("window size: w:%d, h:%d\n", windowSize.GetWidth(), windowSize.GetHeight()); | ||
| 352 | + DevelWindow::EnableFloatingMode(window, true); | ||
| 353 | + | ||
| 354 | + if ((local_x < MARGIN) && (local_y < MARGIN)) // left top corner | ||
| 355 | + { | ||
| 356 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: TOP_LEFT\n", local_x, local_y); | ||
| 357 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::TOP_LEFT); | ||
| 358 | + } | ||
| 359 | + else if ((local_x > (windowSize.GetWidth() - MARGIN)) && (local_y < MARGIN)) // rigth top corner | ||
| 360 | + { | ||
| 361 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: TOP_RIGHT\n", local_x, local_y); | ||
| 362 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::TOP_RIGHT); | ||
| 363 | + } | ||
| 364 | + else if ((local_x > MARGIN) && (local_x < (windowSize.GetWidth() - MARGIN)) && (local_y < MARGIN)) | ||
| 365 | + { | ||
| 366 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: TOP\n", local_x, local_y); | ||
| 367 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::TOP); | ||
| 368 | + } | ||
| 369 | + else if ((local_x < MARGIN) && (local_y < (windowSize.GetHeight() - MARGIN)) && (local_y > MARGIN)) | ||
| 370 | + { | ||
| 371 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: TOP\n", local_x, local_y); | ||
| 372 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::LEFT); | ||
| 373 | + } | ||
| 374 | + else if ((local_x > (windowSize.GetWidth() - MARGIN)) && (local_y < (windowSize.GetHeight() - MARGIN)) && (local_y > MARGIN)) | ||
| 375 | + { | ||
| 376 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: LEFT\n", local_x, local_y); | ||
| 377 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::RIGHT); | ||
| 378 | + } | ||
| 379 | + else if ((local_x < MARGIN) && (local_y > (windowSize.GetHeight() - MARGIN))) // left bottom corner | ||
| 380 | + { | ||
| 381 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: RIGHT\n", local_x, local_y); | ||
| 382 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::BOTTOM_LEFT); | ||
| 383 | + } | ||
| 384 | + else if ((local_x > (windowSize.GetWidth() - MARGIN)) && (local_y > (windowSize.GetHeight() - MARGIN))) // right bottom corner | ||
| 385 | + { | ||
| 386 | + DALI_LOG_RELEASE_INFO("RequestResizeToServer: BOTTOM_RIGHT\n", local_x, local_y); | ||
| 387 | + DevelWindow::RequestResizeToServer(window, WindowResizeDirection::BOTTOM_RIGHT); | ||
| 388 | + } | ||
| 389 | + else | ||
| 390 | + { | ||
| 391 | + DALI_LOG_RELEASE_INFO("RequestMoveToServer\n", local_x, local_y); | ||
| 392 | + DevelWindow::RequestMoveToServer(window); | ||
| 393 | + } | ||
| 394 | + } | ||
| 395 | + return true; | ||
| 396 | + } | ||
| 397 | + | ||
| 398 | + void OnKeyEvent(const KeyEvent &event) | ||
| 399 | + { | ||
| 400 | + Dali::Window window = mApplication.GetWindow(); | ||
| 401 | + if (event.GetState() == KeyEvent::DOWN) | ||
| 402 | + { | ||
| 403 | + if (IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK)) | ||
| 404 | + { | ||
| 405 | + mApplication.Quit(); | ||
| 406 | + } | ||
| 407 | + else if (event.GetKeyName() == "1") | ||
| 408 | + { | ||
| 409 | + DALI_LOG_RELEASE_INFO("Move/Resize Test ::: window move and resize (10, 10) (600 x 400)\n"); | ||
| 410 | + PositionSize windowPosition(10, 10, 600, 400); | ||
| 411 | + DevelWindow::SetPositionSize(window, windowPosition); | ||
| 412 | + } | ||
| 413 | + else if (event.GetKeyName() == "2") | ||
| 414 | + { | ||
| 415 | + DALI_LOG_RELEASE_INFO("Present Callback Test\n"); | ||
| 416 | + | ||
| 417 | + Dali::Window window = mApplication.GetWindow(); | ||
| 418 | + if(bColor == 0) | ||
| 419 | + { | ||
| 420 | + window.SetBackgroundColor(Color::WHITE); | ||
| 421 | + bColor = 1; | ||
| 422 | + } | ||
| 423 | + else | ||
| 424 | + { | ||
| 425 | + window.SetBackgroundColor(Color::BLACK); | ||
| 426 | + bColor = 0; | ||
| 427 | + } | ||
| 428 | + | ||
| 429 | + DevelWindow::AddFramePresentedCallback(window, std::unique_ptr<Dali::CallbackBase>(MakeCallback(this, &WindowExampleController::PresentedCallback)), count); | ||
| 430 | + } | ||
| 431 | + else if (event.GetKeyName() == "3") | ||
| 432 | + { | ||
| 433 | + DALI_LOG_RELEASE_INFO("Send AckWindowRotation test\n"); | ||
| 434 | + if(manual_rotation_flag == true) | ||
| 435 | + { | ||
| 436 | + if(isRotating) | ||
| 437 | + { | ||
| 438 | + DALI_LOG_RELEASE_INFO("Send AckWindowRotation in Key Event Callback\n"); | ||
| 439 | + DevelWindow::SendRotationCompletedAcknowledgement(window); | ||
| 440 | + manual_rotation_flag = false; | ||
| 441 | + isRotating = false; | ||
| 442 | + } | ||
| 443 | + else | ||
| 444 | + { | ||
| 445 | + DALI_LOG_RELEASE_INFO("is not Rotating\n"); | ||
| 446 | + } | ||
| 447 | + } | ||
| 448 | + else if (event.GetKeyName() == "4") | ||
| 449 | + { | ||
| 450 | + DALI_LOG_RELEASE_INFO("Set Manual Window Rotation Test\n"); | ||
| 451 | + if(manual_rotation_flag) | ||
| 452 | + { | ||
| 453 | + mTimer.Start(); | ||
| 454 | + } | ||
| 455 | + else | ||
| 456 | + { | ||
| 457 | + mTimer.Stop(); | ||
| 458 | + } | ||
| 459 | + DALI_LOG_RELEASE_INFO("call SetNeedsRotationCompletedAcknowledgement with flag %d\n", manual_rotation_flag); | ||
| 460 | + DevelWindow::SetNeedsRotationCompletedAcknowledgement(window, manual_rotation_flag); | ||
| 461 | + } | ||
| 462 | + else | ||
| 463 | + { | ||
| 464 | + DALI_LOG_RELEASE_INFO("set flag %d\n", manual_rotation_flag); | ||
| 465 | + manual_rotation_flag = true; | ||
| 466 | + } | ||
| 467 | + } | ||
| 468 | + else if (event.GetKeyName() == "5") | ||
| 469 | + { | ||
| 470 | + DALI_LOG_RELEASE_INFO("Window Rotation and Resize test together\n"); | ||
| 471 | + if(!bChangedOrientation) | ||
| 472 | + { | ||
| 473 | + DALI_LOG_RELEASE_INFO("Both Window Rotation and Resize Test\n"); | ||
| 474 | + bChangedOrientation = true; | ||
| 475 | + } | ||
| 476 | + else | ||
| 477 | + { | ||
| 478 | + DALI_LOG_RELEASE_INFO("Only Window Rotation Test\n"); | ||
| 479 | + bChangedOrientation = false; | ||
| 480 | + } | ||
| 481 | + } | ||
| 482 | + else if (event.GetKeyName() == "6") | ||
| 483 | + { | ||
| 484 | + DALI_LOG_RELEASE_INFO("Maximize Test\n"); | ||
| 485 | + if(DevelWindow::IsMaximized(window)) | ||
| 486 | + { | ||
| 487 | + DevelWindow::Maximize(window, false); | ||
| 488 | + } | ||
| 489 | + else | ||
| 490 | + { | ||
| 491 | + DevelWindow::Maximize(window, true); | ||
| 492 | + } | ||
| 493 | + } | ||
| 494 | + else if (event.GetKeyName() == "7") | ||
| 495 | + { | ||
| 496 | + DALI_LOG_RELEASE_INFO("Minimize Test\n"); | ||
| 497 | + if(DevelWindow::IsMinimized(window)) | ||
| 498 | + { | ||
| 499 | + DevelWindow::Minimize(window, false); | ||
| 500 | + } | ||
| 501 | + else | ||
| 502 | + { | ||
| 503 | + DevelWindow::Minimize(window, true); | ||
| 504 | + } | ||
| 505 | + } | ||
| 506 | + | ||
| 507 | + else if (event.GetKeyName() == "8") | ||
| 508 | + { | ||
| 509 | + DALI_LOG_RELEASE_INFO("Set/Get Full Screen window Test\n"); | ||
| 510 | + if(DevelWindow::GetFullScreen(window)) | ||
| 511 | + { | ||
| 512 | + DevelWindow::SetFullScreen(window, false); | ||
| 513 | + } | ||
| 514 | + else | ||
| 515 | + { | ||
| 516 | + DevelWindow::SetFullScreen(window, true); | ||
| 517 | + } | ||
| 518 | + | ||
| 519 | + } | ||
| 520 | + else if (event.GetKeyName() == "9") | ||
| 521 | + { | ||
| 522 | + DALI_LOG_RELEASE_INFO("Sub window Test\n"); | ||
| 523 | + CreateSubWindow(); | ||
| 524 | + } | ||
| 525 | + else if(event.GetKeyName() == "0") | ||
| 526 | + { | ||
| 527 | + // scissor test for Window Rotation | ||
| 528 | + // Toggle the clipping mode on mClippingControl if any other actor by pressing any key | ||
| 529 | + DALI_LOG_RELEASE_INFO("Scissor Test\n"); | ||
| 530 | + ClippingMode::Type currentMode; | ||
| 531 | + mClipControl.GetProperty( Actor::Property::CLIPPING_MODE ).Get( currentMode ); | ||
| 532 | + mClipControl.SetProperty( Actor::Property::CLIPPING_MODE, | ||
| 533 | + ( ( currentMode == ClippingMode::DISABLED ) ? ClippingMode::CLIP_TO_BOUNDING_BOX : ClippingMode::DISABLED ) ); | ||
| 534 | + } | ||
| 535 | + | ||
| 536 | + } | ||
| 537 | + } | ||
| 538 | + | ||
| 539 | + void OnAuxMessageEvent(const std::string &key, const std::string &value, const Property::Array &options) | ||
| 540 | + { | ||
| 541 | + if (!key.empty()) | ||
| 542 | + { | ||
| 543 | + std::cout << "Key: " << key << std::endl; | ||
| 544 | + if (!value.empty()) | ||
| 545 | + { | ||
| 546 | + std::cout << "Value : " << value << std::endl; | ||
| 547 | + } | ||
| 548 | + | ||
| 549 | + if (!options.Empty()) | ||
| 550 | + { | ||
| 551 | + uint32_t options_count = static_cast<uint32_t>(options.Count()); | ||
| 552 | + for (uint32_t i(0); i != options_count; ++i) | ||
| 553 | + { | ||
| 554 | + std::cout << "Option : " << options.GetElementAt(i) << std::endl; | ||
| 555 | + } | ||
| 556 | + } | ||
| 557 | + } | ||
| 558 | + } | ||
| 559 | + | ||
| 560 | +private: | ||
| 561 | + Application &mApplication; | ||
| 562 | + Control mClipControl; | ||
| 563 | + bool manual_rotation_flag; | ||
| 564 | + int rotation_count; | ||
| 565 | + int rot; | ||
| 566 | + Timer mTimer; | ||
| 567 | + TextLabel mTextLabel2; | ||
| 568 | + bool enableTimer; | ||
| 569 | + bool bChangedOrientation; | ||
| 570 | + bool isRotating; | ||
| 571 | + bool bColor; | ||
| 572 | + | ||
| 573 | + Dali::Window mSecondWindow; | ||
| 574 | + Dali::WindowOrientation currentOrientation; | ||
| 575 | + | ||
| 576 | + CallbackBase* mPresentCallback{}; | ||
| 577 | +}; | ||
| 578 | + | ||
| 579 | +int DALI_EXPORT_API main(int argc, char **argv) | ||
| 580 | +{ | ||
| 581 | + Application application = Application::New(&argc, &argv); | ||
| 582 | + WindowExampleController test(application); | ||
| 583 | + application.MainLoop(); | ||
| 584 | + return 0; | ||
| 585 | +} |
resources/po/en_GB.po
| @@ -331,6 +331,9 @@ msgstr "Waves" | @@ -331,6 +331,9 @@ msgstr "Waves" | ||
| 331 | msgid "DALI_DEMO_STR_TITLE_WEB_VIEW" | 331 | msgid "DALI_DEMO_STR_TITLE_WEB_VIEW" |
| 332 | msgstr "Web View" | 332 | msgstr "Web View" |
| 333 | 333 | ||
| 334 | +msgid "DALI_DEMO_STR_TITLE_WINDOW" | ||
| 335 | +msgstr "Window" | ||
| 336 | + | ||
| 334 | msgid "DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES" | 337 | msgid "DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES" |
| 335 | msgstr "Animated Vector Images" | 338 | msgstr "Animated Vector Images" |
| 336 | 339 |
resources/po/en_US.po
| @@ -337,6 +337,9 @@ msgstr "PBR" | @@ -337,6 +337,9 @@ msgstr "PBR" | ||
| 337 | msgid "DALI_DEMO_STR_TITLE_WEB_VIEW" | 337 | msgid "DALI_DEMO_STR_TITLE_WEB_VIEW" |
| 338 | msgstr "Web View" | 338 | msgstr "Web View" |
| 339 | 339 | ||
| 340 | +msgid "DALI_DEMO_STR_TITLE_WINDOW" | ||
| 341 | +msgstr "Window" | ||
| 342 | + | ||
| 340 | msgid "DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES" | 343 | msgid "DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES" |
| 341 | msgstr "Animated Vector Images" | 344 | msgstr "Animated Vector Images" |
| 342 | 345 |
shared/dali-demo-strings.h
| @@ -148,6 +148,7 @@ extern "C" | @@ -148,6 +148,7 @@ extern "C" | ||
| 148 | #define DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS") | 148 | #define DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS") |
| 149 | #define DALI_DEMO_STR_TITLE_WAVES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_WAVES") | 149 | #define DALI_DEMO_STR_TITLE_WAVES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_WAVES") |
| 150 | #define DALI_DEMO_STR_TITLE_WEB_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_WEB_VIEW") | 150 | #define DALI_DEMO_STR_TITLE_WEB_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_WEB_VIEW") |
| 151 | +#define DALI_DEMO_STR_TITLE_WINDOW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_WINDOW") | ||
| 151 | #define DALI_DEMO_STR_TITLE_TEXT_RENDERER dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_RENDERER") | 152 | #define DALI_DEMO_STR_TITLE_TEXT_RENDERER dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_RENDERER") |
| 152 | #define DALI_DEMO_STR_TITLE_TEXT_VISUAL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_VISUAL") | 153 | #define DALI_DEMO_STR_TITLE_TEXT_VISUAL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_VISUAL") |
| 153 | #define DALI_DEMO_STR_TITLE_TEXT_LABEL_BITMAP_FONT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_LABEL_BITMAP_FONT") | 154 | #define DALI_DEMO_STR_TITLE_TEXT_LABEL_BITMAP_FONT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_LABEL_BITMAP_FONT") |
| @@ -269,6 +270,7 @@ extern "C" | @@ -269,6 +270,7 @@ extern "C" | ||
| 269 | #define DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS "Visual Transitions" | 270 | #define DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS "Visual Transitions" |
| 270 | #define DALI_DEMO_STR_TITLE_WAVES "Waves" | 271 | #define DALI_DEMO_STR_TITLE_WAVES "Waves" |
| 271 | #define DALI_DEMO_STR_TITLE_WEB_VIEW "Web View" | 272 | #define DALI_DEMO_STR_TITLE_WEB_VIEW "Web View" |
| 273 | +#define DALI_DEMO_STR_TITLE_WINDOW "Window" | ||
| 272 | #define DALI_DEMO_STR_TITLE_TEXT_RENDERER "Text Renderer" | 274 | #define DALI_DEMO_STR_TITLE_TEXT_RENDERER "Text Renderer" |
| 273 | #define DALI_DEMO_STR_TITLE_TEXT_VISUAL "Text Visual" | 275 | #define DALI_DEMO_STR_TITLE_TEXT_VISUAL "Text Visual" |
| 274 | #define DALI_DEMO_STR_TITLE_TEXT_LABEL_BITMAP_FONT "Text Bitmap Font" | 276 | #define DALI_DEMO_STR_TITLE_TEXT_LABEL_BITMAP_FONT "Text Bitmap Font" |