SET(CAPI_LIB "dali-internal")
SET(TC_SOURCES
+ utc-Dali-Internal-Core.cpp
utc-Dali-Internal-Handles.cpp
utc-Dali-Internal-ImageFactory.cpp
utc-Dali-Internal-ResourceClient.cpp
--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+
+#include <dali-test-suite-utils.h>
+
+// Internal headers are allowed here
+
+
+using namespace Dali;
+
+void utc_dali_internal_core_startup()
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_internal_core_cleanup()
+{
+ test_return_value = TET_PASS;
+}
+
+
+int UtcDaliCoreTopMargin(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::Integration::Core::SetTopMargin");
+
+ Stage stage = Stage::GetCurrent();
+
+ // Test Stage size without top-margin
+
+ const unsigned int initialWidth( stage.GetSize().width );
+ const unsigned int initialHeight( stage.GetSize().height );
+
+ DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_WIDTH, initialWidth, TEST_LOCATION );
+ DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_HEIGHT, initialHeight, TEST_LOCATION );
+
+ // Retest with top-margin
+
+ unsigned int margin( 10 );
+ application.SetTopMargin( margin );
+
+ const unsigned int newWidth( stage.GetSize().width );
+ const unsigned int newHeight( stage.GetSize().height );
+
+ DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_WIDTH, newWidth, TEST_LOCATION );
+ DALI_TEST_EQUALS( (TestApplication::DEFAULT_SURFACE_HEIGHT - margin), newHeight, TEST_LOCATION );
+
+ END_TEST;
+}
mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
}
+void TestApplication::SetTopMargin( unsigned int margin )
+{
+ mCore->SetTopMargin( margin );
+}
+
void TestApplication::DoUpdate( unsigned int intervalMilliseconds, const char* location )
{
if( GetUpdateStatus() == 0 &&
void ProcessEvent(const Integration::Event& event);
void SendNotification();
void SetSurfaceWidth( unsigned int width, unsigned height );
+ void SetTopMargin( unsigned int margin );
bool Render( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL );
unsigned int GetUpdateStatus();
bool UpdateOnly( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL );
mImpl->SurfaceResized(width, height);
}
+void Core::SetTopMargin( unsigned int margin )
+{
+ mImpl->SetTopMargin(margin);
+}
+
void Core::SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical)
{
mImpl->SetDpi(dpiHorizontal, dpiVertical);
*/
void SurfaceResized(unsigned int width, unsigned int height);
+ /**
+ * Notify the Core about the top margin size.
+ * Available stage size is reduced by this size.
+ * The stage is located below the size at the top of the display
+ * It is mainly useful for indicator in mobile device
+ * @param[in] margin margin size
+ */
+ void SetTopMargin( unsigned int margin );
+
// Core setters
/**
void Core::SurfaceResized( unsigned int width, unsigned int height )
{
- mStage->SetSize( width, height );
- mRelayoutController->SetStageSize( width, height );
+ mStage->SurfaceResized( width, height );
+
+ // The stage-size may be less than surface-size (reduced by top-margin)
+ Vector2 size = mStage->GetSize();
+ mRelayoutController->SetStageSize( size.width, size.height );
+}
+
+void Core::SetTopMargin( unsigned int margin )
+{
+ mStage->SetTopMargin( margin );
+
+ // The stage-size may be less than surface-size (reduced by top-margin)
+ Vector2 size = mStage->GetSize();
+ mRelayoutController->SetStageSize( size.width, size.height );
}
void Core::SetDpi( unsigned int dpiHorizontal, unsigned int dpiVertical )
void SurfaceResized(unsigned int width, unsigned int height);
/**
+ * @copydoc Dali::Integration::Core::SetTopMargin( unsigned int margin )
+ */
+ void SetTopMargin( unsigned int margin );
+
+ /**
* @copydoc Dali::Integration::Core::SetDpi(unsigned int, unsigned int)
*/
void SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical);
mRootLayer->Remove( actor );
}
-void Stage::SetSize(float width, float height)
+void Stage::SurfaceResized(float width, float height)
{
+ mSurfaceSize.width = width;
+ mSurfaceSize.height = height;
+
// Internally we want to report the actual size of the stage.
- mSize.width = width;
- mSize.height = height;
+ mSize.width = width;
+ mSize.height = height - mTopMargin;
// Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
- mDefaultCamera->SetPerspectiveProjection( mSize );
+ mDefaultCamera->SetPerspectiveProjection( mSurfaceSize );
+
+ // Adjust the camera height to allow for top-margin
+ SetDefaultCameraPosition();
- // The depth of the stage gets set to the maximun of these values
- mRootLayer->SetSize( mSize );
+ mRootLayer->SetSize( mSize.width, mSize.height );
// Repeat for SystemOverlay actors
if( mSystemOverlay )
{
- mSystemOverlay->GetImpl()->SetSize( mSize.width, mSize.height );
+ // Note that the SystemOverlay has a separate camera, configured for the full surface-size.
+ // This will remain unaffected by changes in SetDefaultCameraPosition()
+ mSystemOverlay->GetImpl()->SetSize( width, height );
}
SetDefaultSurfaceRectMessage( mUpdateManager, Rect<int>( 0, 0, width, height ) );
return mSize;
}
+void Stage::SetTopMargin( unsigned int margin )
+{
+ if (mTopMargin == margin)
+ {
+ return;
+ }
+ mTopMargin = margin;
+
+ mSize.width = mSurfaceSize.width;
+ mSize.height = mSurfaceSize.height - mTopMargin;
+
+ // Adjust the camera height to allow for top-margin
+ SetDefaultCameraPosition();
+
+ mRootLayer->SetSize( mSize.width, mSize.height );
+}
+
RenderTaskList& Stage::GetRenderTaskList() const
{
return *mRenderTaskList;
Add(*(mDefaultCamera.Get()));
}
+void Stage::SetDefaultCameraPosition()
+{
+ mDefaultCamera->SetY( -(static_cast<float>(mTopMargin) * 0.5f) );
+}
+
Actor& Stage::GetDefaultRootActor()
{
return *mRootLayer;
mBackgroundColor(Dali::Stage::DEFAULT_BACKGROUND_COLOR),
mViewMode( MONO ),
mStereoBase( DEFAULT_STEREO_BASE ),
+ mTopMargin( 0 ),
mSystemOverlay(NULL)
{
}
void Remove( Actor& actor );
/**
- * Sets the size of the stage and indirectly, the root actor.
- * @param [in] width The new width.
- * @param [in] height The new height.
+ * Used to calculate the size of the stage and indirectly, the root actor.
+ * @param [in] width The new surface width.
+ * @param [in] height The new surface height.
*/
- void SetSize( float width, float height );
+ void SurfaceResized( float width, float height );
+
+ /**
+ * Sets the top margin size.
+ * Available stage size is reduced by this size.
+ * The stage is located below the size at the top of the display
+ * initial size is zero before it is assigned
+ * @param[in] margin margin size
+ */
+ void SetTopMargin( unsigned int margin );
/**
* Returns the size of the Stage in pixels as a Vector.
void CreateDefaultCameraActor();
/**
+ * Set position of default camera for current stage size
+ */
+ void SetDefaultCameraPosition();
+
+ /**
* From RenderTaskDefaults; retrieve the default root actor.
* @return The default root actor.
*/
NotificationManager& mNotificationManager;
- // The Actual size of the stage.
+ // The stage-size may be less than surface-size (reduced by top-margin)
Vector2 mSize;
+ Vector2 mSurfaceSize;
// Cached for public GetBackgroundColor()
Vector4 mBackgroundColor;
ViewMode mViewMode;
float mStereoBase;
+ unsigned int mTopMargin;
Vector2 mDpi;
// The object registry
bool mCullMode: 1; ///< Whether renderers should be frustum culled
FrameBufferTexture* mRenderTarget;
- Viewport mViewport;
State mState; ///< Render state.
unsigned int mRefreshRate; ///< REFRESH_ONCE, REFRESH_ALWAYS or render every N frames