--- /dev/null
+#ifndef DALI_DEMO_LAYOUTING_EXAMPLE_H
+#define DALI_DEMO_LAYOUTING_EXAMPLE_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+namespace Demo
+{
+
+/**
+ * @brief Abstract base class for layouting examples.
+ */
+class Example
+{
+public:
+ /// Should be overridden by deriving classes to create the required Layouting example
+ virtual void Create() = 0;
+
+ /// Should be overridden by deriving classes to remove their layouting example from stage
+ virtual void Remove() = 0;
+
+ /// Virtual destructor
+ virtual ~Example() = default;
+};
+
+} // namespace Demo
+
+#endif // DALI_DEMO_LAYOUTING_EXAMPLE_H
*
*/
+// EXTERNAL INCLUDES
+#include <memory>
#include <string>
-#include "shared/view.h"
-#include "linear-example.h"
-#include "padding-example.h"
#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
+// INTERNAL INCLUDES
+#include "shared/view.h"
+#include "linear-example.h"
+#include "padding-example.h"
+#include "example.h"
+
using namespace Dali;
using namespace Dali::Toolkit;
const char* BACKGROUND_IMAGE( DEMO_IMAGE_DIR "lake_front.jpg" );
const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
-const char* APPLICATION_TITLE( "Layout tester" );
+const char* APPLICATION_TITLE( "Layout Tester" );
-} // namespace
+typedef std::unique_ptr< Demo::Example > ExamplePointer;
+typedef std::vector< ExamplePointer > ExampleContainer;
+
+/// All layouting examples to be shown should be added to this method
+void CreateExamples( ExampleContainer& container )
+{
+ container.push_back( ExamplePointer( new Demo::LinearExample ) );
+ container.push_back( ExamplePointer( new Demo::PaddingExample ) );
+}
+
+} // anonymous namespace
class LayoutingExample: public ConnectionTracker
{
LayoutingExample( Application& application )
: mApplication( application ),
- mLinearExample(),
- mPaddedExample(),
+ mLayoutingExamples(),
mLayoutIndex( 0 )
{
// Connect to the Application's Init signal
mApplication.InitSignal().Connect( this, &LayoutingExample::Create );
}
- ~LayoutingExample()
- {
- // Nothing to do here
- }
+private:
void Create( Application& application )
{
- // The Init signal is received once (only) during the Application lifetime
-
auto stage = Stage::GetCurrent();
stage.KeyEventSignal().Connect( this, &LayoutingExample::OnKeyEvent );
mNextLayout.SetSize(175, 50);
toolbar.Add( mNextLayout );
- mLinearExample.Demo::LinearExample::Create();
+ CreateExamples( mLayoutingExamples );
+ if( ! mLayoutingExamples.empty() )
+ {
+ mLayoutingExamples[ mLayoutIndex ]->Create();
+ }
}
bool ChangeLayout( Button button )
{
- mLayoutIndex++;
-
- switch( mLayoutIndex )
+ if( ! mLayoutingExamples.empty() )
{
- case 1 :
- {
- mLinearExample.Remove();
- mPaddedExample.Create();
- break;
- }
- case 2 :
- {
- mPaddedExample.Remove();
- mNextLayout.SetProperty( Toolkit::Button::Property::LABEL, "end of test");
- mNextLayout.SetProperty( Toolkit::Button::Property::DISABLED, true );
- break;
- }
- default :
- {
- break;
- }
+ mLayoutingExamples[ mLayoutIndex ]->Remove();
+ mLayoutIndex = ( mLayoutIndex + 1 ) % mLayoutingExamples.size();
+ mLayoutingExamples[ mLayoutIndex ]->Create();
}
-
return true;
}
-private:
/**
* Main key event handler
*/
private:
Application& mApplication;
- Demo::LinearExample mLinearExample;
- Demo::PaddingExample mPaddedExample;
+ ExampleContainer mLayoutingExamples;
PushButton mNextLayout;
unsigned int mLayoutIndex;
};
#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include "example.h"
+
using namespace Dali;
using namespace Dali::Toolkit;
* @brief Example of a Linear Layout with mirror feature and
* tranisition from horizontal to vertical.
*/
-class LinearExample: public ConnectionTracker
+class LinearExample final: public ConnectionTracker, public Example
{
-
public:
// Creates a Linear Layout Example and displays it.
- void Create();
+ virtual void Create() override;
// Remove and destroy this layout
- void Remove();
+ virtual void Remove() override;
private:
PushButton mDirectionButton;
PushButton mRotateButton;
Control mLinearContainer;
- bool mDirection;
+ bool mDirection = false;
bool mIsHorizontal = true;
}; // class LinearContainer
} // namespace Demo
-#endif //DALI_DEMO_LINEAR_CONTAINER_H
\ No newline at end of file
+#endif //DALI_DEMO_LINEAR_CONTAINER_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
stage.Add( mHorizontalBox );
- for( unsigned int x = 0; x < NUMBER_OF_IMAGE_VIEWS; x++ )
- {
- mToggleButton = Toolkit::PushButton::New();
- mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Toggle Padding on #2" );
- mToggleButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
- mToggleButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
- mToggleButton.ClickedSignal().Connect( this, &Demo::PaddingExample::ChangePaddingClicked );
- mToggleButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
- mToggleButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
+ mToggleButton = Toolkit::PushButton::New();
+ mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Toggle Padding on #2" );
+ mToggleButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+ mToggleButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+ mToggleButton.ClickedSignal().Connect( this, &Demo::PaddingExample::ChangePaddingClicked );
+ mToggleButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+ mToggleButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
- stage.Add( mToggleButton );
+ stage.Add( mToggleButton );
+ for( unsigned int x = 0; x < NUMBER_OF_IMAGE_VIEWS; x++ )
+ {
CreateChildImageView( mImageViews[x], DEMO_IMAGE_DIR "gallery-small-23.jpg" , Size(100.0f, 100.0f) );
// Set Padding for second ImageView
return true;
}
-} // namespace Demo
\ No newline at end of file
+} // namespace Demo
#define DALI_DEMO_PADDING_EXAMPLE_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include "example.h"
+
using namespace Dali;
using namespace Dali::Toolkit;
* @brief Example of a Linear Layout with padding applied, enables updating of padding values for
* one of the children.
*/
-class PaddingExample: public ConnectionTracker
+class PaddingExample final: public ConnectionTracker, public Example
{
public:
static const unsigned int NUMBER_OF_IMAGE_VIEWS = 3;
// Create a Linear layout of ImagesViews, one with a Margin, One with padding.
- void Create();
+ void Create() override;
// Remove created Layout
- void Remove();
+ void Remove() override;
private: