summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAdeel Kazmi <adeel.kazmi@samsung.com>2022-04-06 16:49:06 +0100
committerAdeel Kazmi <adeel.kazmi@samsung.com>2022-04-06 16:49:06 +0100
commite42f5c3df78b55f46060ebc18e5638ad01f2e1ed (patch)
tree50ac8cd24599c903522e8200acc5827e397e10e1 /examples
parent28cd413bce8735b3e6693415c306fc8a4999d314 (diff)
downloaddali-demo-e42f5c3df78b55f46060ebc18e5638ad01f2e1ed.tar.gz
dali-demo-e42f5c3df78b55f46060ebc18e5638ad01f2e1ed.tar.bz2
dali-demo-e42f5c3df78b55f46060ebc18e5638ad01f2e1ed.zip
Ensured some examples work well in landscape
Change-Id: I471f5cf47e8e8582b40d63be2b5d40c2b5393993
Diffstat (limited to 'examples')
-rw-r--r--examples/bezier-curve/bezier-curve-example.cpp31
-rw-r--r--examples/drag-and-drop/drag-and-drop-example.cpp14
-rw-r--r--examples/image-view-alpha-blending/image-view-alpha-blending-example.cpp9
-rw-r--r--examples/rendering-basic-light/rendering-basic-light-example.cpp9
-rw-r--r--examples/rendering-cube/rendering-cube.cpp9
-rw-r--r--examples/rendering-textured-cube/rendering-textured-cube.cpp9
-rw-r--r--examples/text-label/text-label-example.cpp3
7 files changed, 56 insertions, 28 deletions
diff --git a/examples/bezier-curve/bezier-curve-example.cpp b/examples/bezier-curve/bezier-curve-example.cpp
index 3f5425ca..d2c285df 100644
--- a/examples/bezier-curve/bezier-curve-example.cpp
+++ b/examples/bezier-curve/bezier-curve-example.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -123,6 +123,22 @@ public:
{
Window window = mApplication.GetWindow();
window.KeyEventSignal().Connect(this, &BezierCurveExample::OnKeyEvent);
+ const Vector2 windowSize = window.GetSize();
+ const bool orientationPortrait = windowSize.width < windowSize.height;
+
+ unsigned int tableViewRows = 5;
+ unsigned int tableViewColumns = 1;
+ unsigned int rowPositionAdder = 1;
+ TableView::CellPosition gridPosition{1,0};
+
+ // Change layout if we're in landscape mode
+ if(!orientationPortrait)
+ {
+ tableViewRows = 4;
+ tableViewColumns = 2;
+ rowPositionAdder = 0;
+ gridPosition = {0,1,4,1};
+ }
CreateBackground(window);
@@ -135,8 +151,7 @@ public:
mContentLayer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
window.Add(mContentLayer);
- // 6 rows: title, grid, coords, play, anim1, anim2
- TableView contentLayout = TableView::New(5, 1);
+ TableView contentLayout = TableView::New(tableViewRows, tableViewColumns);
contentLayout.SetProperty(Dali::Actor::Property::NAME, "contentLayout");
contentLayout.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
contentLayout.SetCellPadding(Size(30, 30));
@@ -161,7 +176,7 @@ public:
mGrid.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
mGrid.SetBackgroundColor(GRID_BACKGROUND_COLOR);
- contentLayout.Add(mGrid);
+ contentLayout.AddChild(mGrid, gridPosition);
contentLayout.SetCellAlignment(1, HorizontalAlignment::CENTER, VerticalAlignment::CENTER);
CreateCubic(mGrid);
CreateControlPoints(mGrid); // Control points constrained to double height of grid
@@ -175,7 +190,7 @@ public:
contentLayout.Add(mCoefficientLabel);
SetLabel(Vector2(0, 0), Vector2(1, 1));
- contentLayout.SetCellAlignment(2, HorizontalAlignment::CENTER, VerticalAlignment::CENTER);
+ contentLayout.SetCellAlignment(1 + rowPositionAdder, HorizontalAlignment::CENTER, VerticalAlignment::CENTER);
contentLayout.SetFitHeight(2);
// Setup Play button and 2 icons to show off current anim and linear anim
@@ -187,8 +202,8 @@ public:
play.ClickedSignal().Connect(this, &BezierCurveExample::OnPlayClicked);
contentLayout.Add(play);
- contentLayout.SetCellAlignment(3, HorizontalAlignment::CENTER, VerticalAlignment::CENTER);
- contentLayout.SetFitHeight(3);
+ contentLayout.SetCellAlignment(2 + rowPositionAdder, HorizontalAlignment::CENTER, VerticalAlignment::CENTER);
+ contentLayout.SetFitHeight(2 + rowPositionAdder);
auto animContainer = Control::New();
animContainer.SetProperty(Dali::Actor::Property::NAME, "AnimationContainer");
@@ -203,7 +218,7 @@ public:
animContainer.Add(animRail);
contentLayout.Add(animContainer);
- contentLayout.SetFixedHeight(4, 150);
+ contentLayout.SetFixedHeight(3 + rowPositionAdder, 150);
mAnimIcon1 = ImageView::New(CIRCLE1_IMAGE);
mAnimIcon1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
diff --git a/examples/drag-and-drop/drag-and-drop-example.cpp b/examples/drag-and-drop/drag-and-drop-example.cpp
index 85e2d0be..96ebeb4b 100644
--- a/examples/drag-and-drop/drag-and-drop-example.cpp
+++ b/examples/drag-and-drop/drag-and-drop-example.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,6 +73,7 @@ public:
{
auto window = application.GetWindow();
window.SetBackgroundColor(Color::WHITE);
+ const auto windowHeight = window.GetSize().GetHeight();
mDragAndDropDetector = Dali::Toolkit::DragAndDropDetector::New();
@@ -80,14 +81,19 @@ public:
window.KeyEventSignal().Connect(this, &DragAndDropExample::OnKeyEvent);
TextLabel hintText = TextLabel::New("please drag one textlabel, move and drop on other textlabel");
- hintText.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 700.0f));
- hintText.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
- hintText.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ hintText.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
+ hintText.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
hintText.SetProperty(TextLabel::Property::MULTI_LINE, true);
window.Add(hintText);
for(unsigned int i = 0; i < TEXT_LABEL_NUM; i++)
{
+ // Should be able to fit this and another more so if the height is less, then just stop adding new text labels
+ if((TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * (i + 2)) >= windowHeight)
+ {
+ break;
+ }
+
std::string str = "textlabel ";
mTextLabel[i] = TextLabel::New(str + std::to_string(i));
mTextLabel[i].SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
diff --git a/examples/image-view-alpha-blending/image-view-alpha-blending-example.cpp b/examples/image-view-alpha-blending/image-view-alpha-blending-example.cpp
index ef05f6fc..190a5909 100644
--- a/examples/image-view-alpha-blending/image-view-alpha-blending-example.cpp
+++ b/examples/image-view-alpha-blending/image-view-alpha-blending-example.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,6 +49,9 @@ private:
// Get a handle to the window
Window window = application.GetWindow();
window.KeyEventSignal().Connect(this, &ImageViewAlphaBlendApp::OnKeyEvent);
+ const Vector2 windowSize = window.GetSize();
+ const bool portraitOrientation = windowSize.width < windowSize.height;
+ const Property::Index positionProperty = portraitOrientation ? Actor::Property::POSITION_Y : Actor::Property::POSITION_X;
auto green0 = Vector4(0.f, 1.f, 0.f, 0.25f);
auto green1 = Vector4(0.f, 0.25f, 0.f, 0.25f);
@@ -59,7 +62,7 @@ private:
Toolkit::ImageView imageView0 = CreateImageView(IMAGE_PATH);
imageView0.SetProperty(Actor::Property::SIZE, Vector2(imageSize, imageSize));
imageView0.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
- imageView0.SetProperty(Actor::Property::POSITION_Y, -imageSize * 0.5f);
+ imageView0.SetProperty(positionProperty, -imageSize * 0.5f);
window.Add(imageView0);
Toolkit::ImageView imageView1 = CreateImageView(redGreen0);
imageView1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
@@ -69,7 +72,7 @@ private:
Toolkit::ImageView imageView2 = CreateImageView(IMAGE_PATH);
imageView2.SetProperty(Actor::Property::SIZE, Vector2(imageSize, imageSize));
imageView2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
- imageView2.SetProperty(Actor::Property::POSITION_Y, imageSize * 0.5f);
+ imageView2.SetProperty(positionProperty, imageSize * 0.5f);
window.Add(imageView2);
Toolkit::ImageView imageView3 = CreateImageView(redGreen1);
imageView3.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
diff --git a/examples/rendering-basic-light/rendering-basic-light-example.cpp b/examples/rendering-basic-light/rendering-basic-light-example.cpp
index e11ce151..0be89a77 100644
--- a/examples/rendering-basic-light/rendering-basic-light-example.cpp
+++ b/examples/rendering-basic-light/rendering-basic-light-example.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -295,13 +295,14 @@ public:
void CreateActor()
{
Window window = mApplication.GetWindow();
+ const auto windowSize = window.GetSize();
- float quarterWindowWidth = window.GetSize().GetWidth() * 0.25f;
- mActor = Actor::New();
+ const float quarterWindowSize = std::min(windowSize.GetWidth(), windowSize.GetHeight()) * 0.25f;
+ mActor = Actor::New();
mActor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 1.0f, 0.6f, 1.0f));
mActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
mActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
- mActor.SetProperty(Actor::Property::SIZE, Vector3(quarterWindowWidth, quarterWindowWidth, quarterWindowWidth));
+ mActor.SetProperty(Actor::Property::SIZE, Vector3(quarterWindowSize, quarterWindowSize, quarterWindowSize));
mActor.AddRenderer(mRenderer);
window.Add(mActor);
}
diff --git a/examples/rendering-cube/rendering-cube.cpp b/examples/rendering-cube/rendering-cube.cpp
index 89bd5c90..e09d3f34 100644
--- a/examples/rendering-cube/rendering-cube.cpp
+++ b/examples/rendering-cube/rendering-cube.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -196,13 +196,14 @@ public:
void CreateActor()
{
Window window = mApplication.GetWindow();
+ const auto windowSize = window.GetSize();
- float quarterWindowWidth = window.GetSize().GetWidth() * 0.25f;
- mActor = Actor::New();
+ float quarterWindowSize = std::min(windowSize.GetWidth(), windowSize.GetHeight()) * 0.25f;
+ mActor = Actor::New();
mActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
mActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
mActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
- mActor.SetProperty(Actor::Property::SIZE, Vector3(quarterWindowWidth, quarterWindowWidth, quarterWindowWidth));
+ mActor.SetProperty(Actor::Property::SIZE, Vector3(quarterWindowSize, quarterWindowSize, quarterWindowSize));
mActor.AddRenderer(mRenderer);
window.Add(mActor);
}
diff --git a/examples/rendering-textured-cube/rendering-textured-cube.cpp b/examples/rendering-textured-cube/rendering-textured-cube.cpp
index 32d323db..6e6299a3 100644
--- a/examples/rendering-textured-cube/rendering-textured-cube.cpp
+++ b/examples/rendering-textured-cube/rendering-textured-cube.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -218,13 +218,14 @@ public:
void CreateActor()
{
Window window = mApplication.GetWindow();
+ const auto windowSize = window.GetSize();
- float quarterWindowWidth = window.GetSize().GetWidth() * 0.25f;
- mActor = Actor::New();
+ float quarterWindowSize = std::min(windowSize.GetWidth(), windowSize.GetHeight()) * 0.25f;
+ mActor = Actor::New();
mActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
mActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
mActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
- mActor.SetProperty(Actor::Property::SIZE, Vector3(quarterWindowWidth, quarterWindowWidth, quarterWindowWidth));
+ mActor.SetProperty(Actor::Property::SIZE, Vector3(quarterWindowSize, quarterWindowSize, quarterWindowSize));
mActor.AddRenderer(mRenderer);
window.Add(mActor);
}
diff --git a/examples/text-label/text-label-example.cpp b/examples/text-label/text-label-example.cpp
index f04d074c..bc2765cb 100644
--- a/examples/text-label/text-label-example.cpp
+++ b/examples/text-label/text-label-example.cpp
@@ -207,7 +207,8 @@ public:
mContainer = Control::New();
mContainer.SetProperty(Dali::Actor::Property::NAME, "Container");
mContainer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
- mLayoutSize = Vector2(mWindowSize.width * 0.6f, mWindowSize.width * 0.6f);
+ auto size = std::min(mWindowSize.width, mWindowSize.height) * 0.6f;
+ mLayoutSize = Vector2(size, size);
mContainer.SetProperty(Actor::Property::SIZE, mLayoutSize);
window.Add(mContainer);