#include <sstream>
#include <unistd.h>
#include <dali/devel-api/images/distance-field.h>
+#include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h>
+#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>
// INTERNAL INCLUDES
#include "shared/view.h"
/**
* Creates the background image
*/
-ImageActor CreateBackground( std::string imagePath )
+ImageView CreateBackground( std::string imagePath )
{
Image image = ResourceImage::New( imagePath );
- ImageActor background = ImageActor::New( image );
+ ImageView background = ImageView::New( image );
background.SetName( "BACKGROUND" );
background.SetAnchorPoint( AnchorPoint::CENTER );
background.SetParentOrigin( ParentOrigin::CENTER );
mBackgroundLayer(),
mRootActor(),
mRotateAnimation(),
- mBackground(),
mPressedAnimation(),
mScrollViewLayer(),
mScrollView(),
mTotalPages(),
mScrolling( false ),
mSortAlphabetically( false ),
- mBackgroundAnimsPlaying( false ),
- mVersionPopupShown( false )
+ mBackgroundAnimsPlaying( false )
{
application.InitSignal().Connect( this, &DaliTableView::Initialize );
}
void DaliTableView::Initialize( Application& application )
{
- DemoHelper::RequestThemeChange();
-
Stage::GetCurrent().KeyEventSignal().Connect( this, &DaliTableView::OnKeyEvent );
const Vector2 stageSize = Stage::GetCurrent().GetSize();
// Background
- Actor background = CreateBackground( mBackgroundImagePath );
+ ImageView background = CreateBackground( mBackgroundImagePath );
Stage::GetCurrent().Add( background );
// Render entire content as overlays, as is all on same 2D plane.
mRootActor.SetFitHeight( 0 );
// Add logo
- Dali::ImageActor logo = CreateLogo( LOGO_PATH );
+ ImageView logo = CreateLogo( LOGO_PATH );
logo.SetName( "LOGO_IMAGE" );
logo.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
const float paddingHeight = ( ( 1.f-TABLE_RELATIVE_SIZE.y ) * stageSize.y );
mScrollView.TouchedSignal().Connect( this, &DaliTableView::OnScrollTouched );
mScrollViewLayer = Layer::New();
+
+ // Disable the depth test for performance
+ mScrollViewLayer.SetDepthTestDisabled( true );
mScrollViewLayer.SetAnchorPoint( AnchorPoint::CENTER );
mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER );
- mScrollViewLayer.SetDrawMode( DrawMode::OVERLAY );
mScrollViewLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
// Create solid background colour.
backgroundColourActor.SetParentOrigin( ParentOrigin::CENTER );
backgroundColourActor.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
backgroundColourActor.SetSizeModeFactor( Vector3( 1.0f, 1.5f, 1.0f ) );
- backgroundColourActor.SetZ( BACKGROUND_Z );
+
+ // Force the filled background right to the back
+ backgroundColourActor.SetSortModifier( DemoHelper::BACKGROUND_DEPTH_INDEX );
mScrollViewLayer.Add( backgroundColourActor );
// Populate background and bubbles - needs to be scrollViewLayer so scroll ends show
winHandle.RemoveAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE );
// Set initial orientation
- Dali::Orientation orientation = winHandle.GetOrientation();
-
- unsigned int degrees = winHandle.GetOrientation().GetDegrees();
+ unsigned int degrees = 0;
Rotate( degrees );
- orientation.ChangedSignal().Connect( this, &DaliTableView::OrientationChanged );
+ //orientation.ChangedSignal().Connect( this, &DaliTableView::OrientationChanged );
winHandle.ShowIndicator( Dali::Window::INVISIBLE );
mBackgroundAnimsPlaying = true;
KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &DaliTableView::OnKeyboardPreFocusChange );
- KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated );
+ KeyboardFocusManager::Get().FocusedActorEnterKeySignal().Connect( this, &DaliTableView::OnFocusedActorActivated );
+ AccessibilityManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated );
}
void DaliTableView::ApplyCubeEffectToPages()
const Example& example = ( *iter );
Actor tile = CreateTile( example.name, example.title, Vector3( tileParentMultiplier, tileParentMultiplier, 1.0f ), true );
- FocusManager focusManager = FocusManager::Get();
- focusManager.SetFocusOrder( tile, ++exampleCount );
- focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_LABEL,
+ AccessibilityManager accessibilityManager = AccessibilityManager::Get();
+ accessibilityManager.SetFocusOrder( tile, ++exampleCount );
+ accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_LABEL,
example.title );
- focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_TRAIT, "Tile" );
- focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_HINT,
+ accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_TRAIT, "Tile" );
+ accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_HINT,
"You can run this example" );
tile.SetPadding( Padding( margin, margin, margin, margin ) );
std::string name = actor.GetName();
ExampleMapConstIter iter = mExampleMap.find( name );
- FocusManager focusManager = FocusManager::Get();
+ AccessibilityManager accessibilityManager = AccessibilityManager::Get();
if( iter != mExampleMap.end() )
{
if( name == BUTTON_QUIT )
{
// Move focus to the OK button
- FocusManager focusManager = FocusManager::Get();
+ AccessibilityManager accessibilityManager = AccessibilityManager::Get();
// Enable the group mode and wrap mode
- focusManager.SetGroupMode( true );
- focusManager.SetWrapMode( true );
+ accessibilityManager.SetGroupMode( true );
+ accessibilityManager.SetWrapMode( true );
}
}
else
mScrolling = false;
// move focus to 1st item of new page
- FocusManager focusManager = FocusManager::Get();
- focusManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) );
+ AccessibilityManager accessibilityManager = AccessibilityManager::Get();
+ accessibilityManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) );
}
bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event )
{
if ( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
{
- if ( mVersionPopup && mVersionPopupShown )
+ // If there's a Popup, Hide it if it's contributing to the display in any way (EG. transitioning in or out).
+ // Otherwise quit.
+ if ( mVersionPopup && ( mVersionPopup.GetDisplayState() != Toolkit::Popup::HIDDEN ) )
{
- HideVersionPopup();
+ mVersionPopup.SetDisplayState( Popup::HIDDEN );
}
else
{
dfActor.SetSize( Vector2( randSize, randSize ) );
dfActor.SetParentOrigin( ParentOrigin::CENTER );
+ // Force the bubbles just in front of the solid background
+ dfActor.SetSortModifier( DemoHelper::BACKGROUND_DEPTH_INDEX + 1 );
+
ShaderEffect effect = Toolkit::CreateDistanceFieldEffect();
dfActor.SetShaderEffect( effect );
dfActor.SetColor( randColour );
}
}
-ImageActor DaliTableView::CreateLogo( std::string imagePath )
+ImageView DaliTableView::CreateLogo( std::string imagePath )
{
Image image = ResourceImage::New( imagePath );
- ImageActor logo = ImageActor::New( image );
+ ImageView logo = ImageView::New( image );
logo.SetAnchorPoint( AnchorPoint::CENTER );
logo.SetParentOrigin( ParentOrigin::CENTER );
mAnimationTimer.SetInterval( BACKGROUND_ANIMATION_DURATION );
}
-Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction )
+Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction )
{
Actor nextFocusActor = proposed;
// in the given direction. We should work out which page to scroll to next.
int currentPage = mScrollView.GetCurrentPage();
int newPage = currentPage;
- if( direction == Dali::Toolkit::Control::Left )
+ if( direction == Dali::Toolkit::Control::KeyboardFocus::LEFT )
{
newPage--;
}
- else if( direction == Dali::Toolkit::Control::Right )
+ else if( direction == Dali::Toolkit::Control::KeyboardFocus::RIGHT )
{
newPage++;
}
- newPage = std::max(0, std::min(static_cast<int>(mScrollRulerX->GetTotalPages() - 1), newPage));
+ newPage = std::max(0, std::min(mTotalPages - 1, newPage));
if( newPage == currentPage )
{
- if( direction == Dali::Toolkit::Control::Left )
+ if( direction == Dali::Toolkit::Control::KeyboardFocus::LEFT )
{
- newPage = mScrollRulerX->GetTotalPages() - 1;
- } else if( direction == Dali::Toolkit::Control::Right )
+ newPage = mTotalPages - 1;
+ } else if( direction == Dali::Toolkit::Control::KeyboardFocus::RIGHT )
{
newPage = 0;
}
// Scroll to the page in the given direction
mScrollView.ScrollTo(newPage);
- if( direction == Dali::Toolkit::Control::Left )
+ if( direction == Dali::Toolkit::Control::KeyboardFocus::LEFT )
{
// Work out the cell position for the last tile
int remainingExamples = mExampleList.size() - newPage * EXAMPLES_PER_PAGE;
int colPos = remainingExamples >= EXAMPLES_PER_PAGE ? EXAMPLES_PER_ROW - 1 : ( remainingExamples % EXAMPLES_PER_PAGE - rowPos * EXAMPLES_PER_ROW - 1 );
// Move the focus to the last tile in the new page.
- nextFocusActor = mPages[newPage].GetChildAt(colPos * EXAMPLES_PER_ROW + rowPos);
+ nextFocusActor = mPages[newPage].GetChildAt(rowPos * EXAMPLES_PER_ROW + colPos);
}
else
{
void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap )
{
- if ( !mVersionPopupShown )
+ // Only show if currently fully hidden. If transitioning-out, the transition will not be interrupted.
+ if ( !mVersionPopup || ( mVersionPopup.GetDisplayState() == Toolkit::Popup::HIDDEN ) )
{
if ( !mVersionPopup )
{
std::ostringstream stream;
- stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl << "(" << CORE_BUILD_DATE << ")" << std::endl << std::endl;
- stream << "DALi Adaptor: " << ADAPTOR_MAJOR_VERSION << "." << ADAPTOR_MINOR_VERSION << "." << ADAPTOR_MICRO_VERSION << std::endl << "(" << ADAPTOR_BUILD_DATE << ")" << std::endl << std::endl;
- stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")";
+ stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl << "(" << CORE_BUILD_DATE << ")\n";
+ stream << "DALi Adaptor: " << ADAPTOR_MAJOR_VERSION << "." << ADAPTOR_MINOR_VERSION << "." << ADAPTOR_MICRO_VERSION << std::endl << "(" << ADAPTOR_BUILD_DATE << ")\n";
+ stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")\n";
mVersionPopup = Dali::Toolkit::Popup::New();
- mVersionPopup.SetParentOrigin( ParentOrigin::CENTER );
- mVersionPopup.SetAnchorPoint( AnchorPoint::CENTER );
+
+ Toolkit::TextLabel titleActor = Toolkit::TextLabel::New( "Version information" );
+ titleActor.SetName( "title-actor" );
+ titleActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+
+ Toolkit::TextLabel contentActor = Toolkit::TextLabel::New( stream.str() );
+ contentActor.SetName( "content-actor" );
+ contentActor.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true );
+ contentActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ contentActor.SetPadding( Padding( 0.0f, 0.0f, 20.0f, 0.0f ) );
+
+ mVersionPopup.SetTitle( titleActor );
+ mVersionPopup.SetContent( contentActor );
+
mVersionPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::WIDTH );
mVersionPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
mVersionPopup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
- mVersionPopup.SetTitle( stream.str() );
- mVersionPopup.HideTail();
+
mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup );
- mVersionPopup.HiddenSignal().Connect( this, &DaliTableView::PopupHidden );
+ Stage::GetCurrent().Add( mVersionPopup );
}
- mVersionPopup.Show();
- mVersionPopupShown = true;
+ mVersionPopup.SetDisplayState( Popup::SHOWN );
}
}
void DaliTableView::HideVersionPopup()
{
- if ( mVersionPopup )
- {
- mVersionPopup.Hide();
- }
-}
-
-void DaliTableView::PopupHidden()
-{
- if ( mVersionPopup )
+ // Only hide if currently fully shown. If transitioning-in, the transition will not be interrupted.
+ if ( mVersionPopup && ( mVersionPopup.GetDisplayState() == Toolkit::Popup::SHOWN ) )
{
- mVersionPopupShown = false;
+ mVersionPopup.SetDisplayState( Popup::HIDDEN );
}
}