From 102fd0ff958eca808fbf0c0c3195b20e9baf7282 Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Tue, 28 Jul 2015 15:18:58 +0100 Subject: [PATCH] New Popup implementation Change-Id: I19544f18bd90836c039d045be4ab2d9d5386b37f --- demo/dali-demo.cpp | 1 + demo/dali-table-view.cpp | 55 +- demo/dali-table-view.h | 6 - .../image-scaling-and-filtering-example.cpp | 21 +- examples/popup/popup-example.cpp | 740 +++++++++++++++++++++ .../size-negotiation/size-negotiation-example.cpp | 682 ++++--------------- examples/text-field/text-field-example.cpp | 5 +- resources/images/popup_button_background.png | Bin 0 -> 2975 bytes resources/scripts/popup.json | 316 +++++++++ resources/scripts/super-blur-view.json | 4 +- shared/dali-demo-strings.h | 4 +- 11 files changed, 1216 insertions(+), 618 deletions(-) create mode 100644 examples/popup/popup-example.cpp create mode 100644 resources/images/popup_button_background.png create mode 100644 resources/scripts/popup.json diff --git a/demo/dali-demo.cpp b/demo/dali-demo.cpp index ce22a9a..0bd1ddd 100644 --- a/demo/dali-demo.cpp +++ b/demo/dali-demo.cpp @@ -58,6 +58,7 @@ int main(int argc, char **argv) demo.AddExample(Example("text-label-multi-language.example", DALI_DEMO_STR_TITLE_TEXT_LABEL_MULTI_LANGUAGE)); demo.AddExample(Example("text-label-emojis.example", DALI_DEMO_STR_TITLE_EMOJI_TEXT)); demo.AddExample(Example("size-negotiation.example", DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE)); + demo.AddExample(Example("popup.example", DALI_DEMO_STR_TITLE_POPUP)); demo.AddExample(Example("buttons.example", DALI_DEMO_STR_TITLE_BUTTONS)); demo.AddExample(Example("logging.example", DALI_DEMO_STR_TITLE_LOGGING)); demo.AddExample(Example("mesh-morph.example", DALI_DEMO_STR_TITLE_MESH_MORPH)); diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp index bbe7495..990a787 100644 --- a/demo/dali-table-view.cpp +++ b/demo/dali-table-view.cpp @@ -175,8 +175,7 @@ DaliTableView::DaliTableView( Application& application ) mTotalPages(), mScrolling( false ), mSortAlphabetically( false ), - mBackgroundAnimsPlaying( false ), - mVersionPopupShown( false ) + mBackgroundAnimsPlaying( false ) { application.InitSignal().Connect( this, &DaliTableView::Initialize ); } @@ -697,9 +696,11 @@ void DaliTableView::OnKeyEvent( const KeyEvent& 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 { @@ -977,44 +978,48 @@ bool DaliTableView::OnTileHovered( Actor actor, const HoverEvent& event ) 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 ); } } diff --git a/demo/dali-table-view.h b/demo/dali-table-view.h index bbc4d52..8b1353d 100644 --- a/demo/dali-table-view.h +++ b/demo/dali-table-view.h @@ -367,11 +367,6 @@ private: // Application callbacks & implementation */ void HideVersionPopup(); - /** - * Called when the popup is completely hidden - */ - void PopupHidden(); - /* * @brief Callback called when the buttons page actor is relaid out * @@ -418,7 +413,6 @@ private: bool mScrolling:1; ///< Flag indicating whether view is currently being scrolled bool mSortAlphabetically:1; ///< Sort examples alphabetically. bool mBackgroundAnimsPlaying:1; ///< Are background animations playing - bool mVersionPopupShown:1; ///< Whehter the version popup is shown or not }; diff --git a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp index 3b6e15f..9c05909 100644 --- a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp +++ b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp @@ -384,7 +384,6 @@ public: popup.SetParentOrigin( ParentOrigin::CENTER ); popup.SetAnchorPoint( AnchorPoint::CENTER ); popup.SetSize( POPUP_WIDTH_DP, 0.0f ); - popup.HideTail(); popup.OutsideTouchedSignal().Connect( this, &ImageScalingAndFilteringController::OnPopupOutsideTouched ); @@ -419,7 +418,6 @@ public: Toolkit::TableView fittingModes = Toolkit::TableView::New( 4, 1 ); fittingModes.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); fittingModes.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); - fittingModes.SetBackgroundColor( BACKGROUND_COLOUR ); fittingModes.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE * 0.5 ) ); fittingModes.SetFitHeight( 0 ); fittingModes.SetFitHeight( 1 ); @@ -431,8 +429,9 @@ public: CreatePopupButton( fittingModes, StringFromScalingMode( FittingMode::FIT_WIDTH ) ); CreatePopupButton( fittingModes, StringFromScalingMode( FittingMode::FIT_HEIGHT ) ); - mPopup.Add( fittingModes ); - mPopup.Show(); + mPopup.SetContent( fittingModes ); + Stage::GetCurrent().Add( mPopup ); + mPopup.SetDisplayState( Toolkit::Popup::SHOWN ); } else if( button.GetName() == SAMPLING_BUTTON_ID ) { @@ -442,7 +441,6 @@ public: Toolkit::TableView samplingModes = Toolkit::TableView::New( 6, 1 ); samplingModes.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); samplingModes.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); - samplingModes.SetBackgroundColor( BACKGROUND_COLOUR ); samplingModes.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE * 0.5 ) ); samplingModes.SetFitHeight( 0 ); samplingModes.SetFitHeight( 1 ); @@ -458,8 +456,9 @@ public: CreatePopupButton( samplingModes, StringFromFilterMode( SamplingMode::BOX_THEN_LINEAR ) ); CreatePopupButton( samplingModes, StringFromFilterMode( SamplingMode::NO_FILTER ) ); - mPopup.Add( samplingModes ); - mPopup.Show(); + mPopup.SetContent( samplingModes ); + Stage::GetCurrent().Add( mPopup ); + mPopup.SetDisplayState( Toolkit::Popup::SHOWN ); } else if( CheckFittingModeButton( button, FittingMode::SCALE_TO_FILL) || CheckFittingModeButton( button, FittingMode::SHRINK_TO_FIT) || @@ -487,7 +486,7 @@ public: mFittingMode = mode; mFittingModeButton.SetLabelText( modeName ); ResizeImage(); - mPopup.Hide(); + mPopup.SetDisplayState( Toolkit::Popup::HIDDEN ); mPopup.Reset(); return true; } @@ -502,7 +501,7 @@ public: mSamplingMode = mode; mSamplingModeButton.SetLabelText( modeName ); ResizeImage(); - mPopup.Hide(); + mPopup.SetDisplayState( Toolkit::Popup::HIDDEN ); mPopup.Reset(); return true; } @@ -513,7 +512,7 @@ public: { if( mPopup ) { - mPopup.Hide(); + mPopup.SetDisplayState( Toolkit::Popup::HIDDEN ); mPopup.Reset(); } } @@ -600,7 +599,7 @@ public: { if( mPopup && mPopup.IsVisible() ) { - mPopup.Hide(); + mPopup.SetDisplayState( Toolkit::Popup::HIDDEN ); mPopup.Reset(); } else diff --git a/examples/popup/popup-example.cpp b/examples/popup/popup-example.cpp new file mode 100644 index 0000000..d232eb0 --- /dev/null +++ b/examples/popup/popup-example.cpp @@ -0,0 +1,740 @@ +/* + * Copyright (c) 2015 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 "shared/view.h" +#include +#include +#include + +using namespace Dali; + +using Dali::Toolkit::TextLabel; + +struct ButtonItem +{ + const char* name; + const char* text; +}; + +namespace +{ + +const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "background-gradient.jpg"; +const char* const TOOLBAR_IMAGE = DALI_IMAGE_DIR "top-bar.png"; + +const char* const TOOLBAR_TITLE = "Popup"; + +const char* CONTEXT_DISABLED_ICON_IMAGE = DALI_IMAGE_DIR "icon-scroll-view-carousel.png"; +const char* CONTEXT_ENABLED_ICON_IMAGE = DALI_IMAGE_DIR "icon-scroll-view-spiral.png"; +const char* ANIMATION_FADE_ICON_IMAGE = DALI_IMAGE_DIR "icon-effects-off.png"; +const char* ANIMATION_ZOOM_ICON_IMAGE = DALI_IMAGE_DIR "icon-effects-on.png"; + +const char* const POPUP_BUTTON_TITLE_ID = "POPUP_BUTTON_TITLE"; +const char* const POPUP_BUTTON_BUTTONS_1_ID = "POPUP_BUTTON_BUTTONS_1"; +const char* const POPUP_BUTTON_BUTTONS_2_ID = "POPUP_BUTTON_BUTTONS_2"; +const char* const POPUP_BUTTON_TOAST_ID = "POPUP_BUTTON_TOAST"; +const char* const POPUP_BUTTON_TITLE_CONTENT_BUTTONS_ID = "POPUP_BUTTON_TITLE_CONTENT_BUTTONS"; +const char* const POPUP_BUTTON_CONTENT_TEXT_ID = "POPUP_BUTTON_CONTENT_TEXT"; +const char* const POPUP_BUTTON_CONTENT_IMAGE_ID = "POPUP_BUTTON_CONTENT_IMAGE"; +const char* const POPUP_BUTTON_TITLE_CONTENT_TEXT_ID = "POPUP_BUTTON_TITLE_CONTENT_TEXT"; +const char* const POPUP_BUTTON_TITLE_LARGE_CONTENT_BUTTONS_ID = "POPUP_BUTTON_TITLE_LARGE_CONTENT_BUTTONS"; +const char* const POPUP_BUTTON_FIXED_SIZE_ID = "POPUP_BUTTON_FIXED_SIZE_ID"; +const char* const POPUP_BUTTON_COMPLEX_ID = "POPUP_BUTTON_COMPLEX"; + +// Names to give Popup PushButton controls. +const char* const POPUP_CONTROL_OK_NAME = "control-ok"; +const char* const POPUP_CONTROL_CANCEL_NAME = "control-cancel"; + +const char* const CONTENT_TEXT = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; +const char* const IMAGE1 = DALI_IMAGE_DIR "gallery-medium-5.jpg"; +const char* const IMAGE2 = DALI_IMAGE_DIR "background-magnifier.jpg"; + +// Control area image. +const char* DEFAULT_CONTROL_AREA_IMAGE_PATH = DALI_IMAGE_DIR "popup_button_background.png"; ///< Control area image for the popup. +const Vector4 DEFAULT_CONTROL_AREA_9_PATCH_BORDER( 13.0f, 8.0f, 13.0f, 8.0f ); ///< Nine patch information for the control area background. + +const ButtonItem POPUP_BUTTON_ITEMS[] = { + { POPUP_BUTTON_COMPLEX_ID, "Complex" }, + { POPUP_BUTTON_TOAST_ID, "Toast Popup" }, + { POPUP_BUTTON_TITLE_ID, "Title" }, + { POPUP_BUTTON_BUTTONS_1_ID, "1 Button" }, + { POPUP_BUTTON_BUTTONS_2_ID, "2 Buttons" }, + { POPUP_BUTTON_FIXED_SIZE_ID, "Fixed Size" }, + { POPUP_BUTTON_TITLE_CONTENT_BUTTONS_ID, "Title + Content + Buttons" }, + { POPUP_BUTTON_CONTENT_TEXT_ID, "Content Text" }, + { POPUP_BUTTON_CONTENT_IMAGE_ID, "Content Image" }, + { POPUP_BUTTON_TITLE_CONTENT_TEXT_ID, "Title + Content" }, + { POPUP_BUTTON_TITLE_LARGE_CONTENT_BUTTONS_ID, "Title + Large Content + Buttons" } +}; + +const int POPUP_BUTTON_ITEMS_COUNT = sizeof( POPUP_BUTTON_ITEMS ) / sizeof( POPUP_BUTTON_ITEMS[0] ); + +} // anonymous namespace + + +/** + * This example shows the usage of the Popup class. + */ +class PopupExample: public ConnectionTracker, public Toolkit::ItemFactory +{ +public: + + PopupExample( Application& application ) + : mApplication( application ), + mContextual( false ), + mAnimationFade( true ) + { + // Connect to the Application's Init signal + mApplication.InitSignal().Connect( this, &PopupExample::Create ); + } + + ~PopupExample() + { + // Nothing to do here + } + + void Create( Application& application ) + { + // The Init signal is received once (only) during the Application lifetime + Stage stage = Stage::GetCurrent(); + + // Respond to key events + stage.KeyEventSignal().Connect(this, &PopupExample::OnKeyEvent); + + // Creates a default view with a default tool bar. + // The view is added to the stage. + mContentLayer = DemoHelper::CreateView( application, + mView, + mToolBar, + BACKGROUND_IMAGE, + TOOLBAR_IMAGE, + std::string("") ); + + mTitleActor = DemoHelper::CreateToolBarLabel( "CUSTOM_TOOLBAR_TITLE" ); + mTitleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, TOOLBAR_TITLE ); + + // Add title to the tool bar. + const float padding( DemoHelper::DEFAULT_VIEW_STYLE.mToolBarPadding ); + mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::Padding( padding, padding, padding, padding ) ); + + // Create animation button. + mAnimationButton = Toolkit::PushButton::New(); + mAnimationButton.SetUnselectedImage( ANIMATION_FADE_ICON_IMAGE ); + mAnimationButton.SetSelectedImage( ANIMATION_ZOOM_ICON_IMAGE ); + mAnimationButton.SetTogglableButton( true ); + mAnimationButton.ClickedSignal().Connect( this, &PopupExample::OnAnimationClicked ); + mToolBar.AddControl( mAnimationButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); + + // Create context button. + mContextButton = Toolkit::PushButton::New(); + mContextButton.SetUnselectedImage( CONTEXT_DISABLED_ICON_IMAGE ); + mContextButton.SetSelectedImage( CONTEXT_ENABLED_ICON_IMAGE ); + mContextButton.SetTogglableButton( true ); + mContextButton.ClickedSignal().Connect( this, &PopupExample::OnContextClicked ); + mToolBar.AddControl( mContextButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); + + // Add title to the tool bar. + mItemView = Toolkit::ItemView::New( *this ); + mItemView.SetParentOrigin( ParentOrigin::CENTER ); + mItemView.SetAnchorPoint( AnchorPoint::CENTER ); + mItemView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + + // Use a grid layout for tests + Vector2 stageSize = stage.GetSize(); + Toolkit::ItemLayoutPtr gridLayout = Toolkit::DefaultItemLayout::New( Toolkit::DefaultItemLayout::LIST ); + Vector3 itemSize; + gridLayout->GetItemSize( 0, Vector3( stageSize ), itemSize ); + itemSize.height = stageSize.y / 10; + gridLayout->SetItemSize( itemSize ); + mItemView.AddLayout( *gridLayout ); + + mItemView.ActivateLayout( 0, Vector3(stageSize.x, stageSize.y, stageSize.x), 0.0f ); + + mContentLayer.Add( mItemView ); + } + + bool OnContextClicked( Toolkit::Button button ) + { + mContextual = button.IsSelected(); + return true; + } + + bool OnAnimationClicked( Toolkit::Button button ) + { + mAnimationFade = !button.IsSelected(); + return true; + } + + /** + * This function is designed as a shortcut to convert any resize policies set for a popup to + * ones that will work for contextual mode (for demo purposes). + * Note that in a real-use case example the policies would be set to something appropriate + * manually, but in the case of this demo, the popup is parented from the popup-opening buttons + * and (incorrectly) have their policies as "SIZE_RELATIVE_TO_PARENT". This would create a tiny + * popup that would not be able to contain it's contents, so to illustrate contextual behaviour + * this function converts the old policies and size to new ones that would give the popup the + * same visual appearance. + * @param[in] popup The popup whose policies should be modified. + */ + void SetupContextualResizePolicy( Toolkit::Popup& popup ) + { + Vector2 stageSize = Stage::GetCurrent().GetSize(); + // Some defaults when creating a new fixed size. + // This is NOT a Vector2 so we can modify each dimension in a for-loop. + float newSize[ Dimension::DIMENSION_COUNT ] = { stageSize.x * 0.75f, stageSize.y * 0.75f }; + bool modifySize = false; + + // Loop through each of two dimensions to process them. + for( unsigned int dimension = 0; dimension < 2; ++dimension ) + { + float stageDimensionSize, sizeModeFactor; + Dimension::Type policyDimension = dimension == 0 ? Dimension::WIDTH : Dimension::HEIGHT; + + // Setup information related to the current dimension we are processing. + if( policyDimension == Dimension::WIDTH ) + { + stageDimensionSize = stageSize.x; + sizeModeFactor = popup.GetSizeModeFactor().x; + } + else + { + stageDimensionSize = stageSize.y; + sizeModeFactor = popup.GetSizeModeFactor().y; + } + + bool modifyPolicy = false; + ResizePolicy::Type policy = popup.GetResizePolicy( policyDimension ); + ResizePolicy::Type newPolicy( policy ); + + // Switch on each policy type to determine the new behaviour. + switch( policy ) + { + case ResizePolicy::FIXED: + case ResizePolicy::USE_ASSIGNED_SIZE: + { + break; + } + + case ResizePolicy::USE_NATURAL_SIZE: + case ResizePolicy::FIT_TO_CHILDREN: + case ResizePolicy::DIMENSION_DEPENDENCY: + { + // Set size to 0 so the policy determines size. + // If a non-zero size is set, policy is converted to fixed. + newSize[ dimension ] = 0.0f; + modifySize = true; + break; + } + + // The following cases emulate the three size-mode related resize policies. + case ResizePolicy::FILL_TO_PARENT: + { + newPolicy = ResizePolicy::FIXED; + newSize[ dimension ] = stageDimensionSize; + modifyPolicy = true; + break; + } + + case ResizePolicy::SIZE_RELATIVE_TO_PARENT: + { + newPolicy = ResizePolicy::FIXED; + newSize[ dimension ] = stageDimensionSize * sizeModeFactor; + modifyPolicy = true; + break; + } + + case ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT: + { + newPolicy = ResizePolicy::FIXED; + newSize[ dimension ] = stageDimensionSize + sizeModeFactor; + modifyPolicy = true; + break; + } + } + + if( modifyPolicy ) + { + // Set the new policy for this dimension, if it has been modified. + popup.SetResizePolicy( newPolicy, policyDimension ); + modifySize = true; + } + } + + if( modifySize ) + { + // The size is set once at the end. + popup.SetSize( Vector2( newSize[ 0 ], newSize[ 1 ] ) ); + } + } + + void SetupPopup( Toolkit::Popup popup, Actor parent ) + { + if( mAnimationFade ) + { + popup.SetProperty( Toolkit::Popup::Property::ANIMATION_MODE, "FADE" ); + } + else + { + popup.SetProperty( Toolkit::Popup::Property::ANIMATION_MODE, "ZOOM" ); + } + + if( mContextual ) + { + popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, "BELOW" ); + + // Modify the preset demo resize policies (and size) to contextual ones. + SetupContextualResizePolicy( popup ); + + parent.Add( popup ); + } + else + { + Stage::GetCurrent().Add( popup ); + } + + mPopup.SetDisplayState( Toolkit::Popup::SHOWN ); + } + + void HidePopup() + { + if( mPopup ) + { + mPopup.SetDisplayState( Toolkit::Popup::HIDDEN ); + } + } + + void PopupHidden() + { + if( mPopup ) + { + mPopup.Unparent(); + mPopup.Reset(); + } + } + + Toolkit::Popup CreatePopup() + { + Stage stage = Stage::GetCurrent(); + const float POPUP_WIDTH_DP = stage.GetSize().width * 0.75f; + + Toolkit::Popup popup = Toolkit::Popup::New(); + popup.SetName( "popup" ); + popup.SetParentOrigin( ParentOrigin::CENTER ); + popup.SetAnchorPoint( AnchorPoint::CENTER ); + popup.SetSize( POPUP_WIDTH_DP, 0.0f ); + popup.SetProperty( Toolkit::Popup::Property::TAIL_VISIBILITY, false ); + + popup.OutsideTouchedSignal().Connect( this, &PopupExample::HidePopup ); + popup.HiddenSignal().Connect( this, &PopupExample::PopupHidden ); + + return popup; + } + + Toolkit::Popup CreateConfirmationPopup( int numberOfButtons ) + { + Toolkit::Popup confirmationPopup = Toolkit::Popup::New(); + confirmationPopup.SetName( "MAIN-POPUP-SELF" ); + + if( numberOfButtons > 0 ) + { + // Start with a control area image. + ImageActor footer = ImageActor::New( ResourceImage::New( DEFAULT_CONTROL_AREA_IMAGE_PATH ) ); + // Nine patch information is only used for the default control area image. + footer.SetStyle( ImageActor::STYLE_NINE_PATCH ); + footer.SetNinePatchBorder( DEFAULT_CONTROL_AREA_9_PATCH_BORDER ); + footer.SetName( "control-area-image" ); + // Set up the container's layout. + footer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + footer.SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT ); + footer.SetSize( 0.0f, 80.0f ); + footer.SetAnchorPoint( AnchorPoint::CENTER ); + footer.SetParentOrigin( ParentOrigin::CENTER ); + + Actor okButton = CreateOKButton(); + okButton.SetParentOrigin( ParentOrigin::CENTER ); + okButton.SetAnchorPoint( AnchorPoint::CENTER ); + okButton.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS ); + okButton.SetSizeModeFactor( Vector3( -20.0f, -20.0f, 0.0 ) ); + + if( numberOfButtons > 1 ) + { + Toolkit::TableView controlLayout = Toolkit::TableView::New( 1, 2 ); + controlLayout.SetParentOrigin( ParentOrigin::CENTER ); + controlLayout.SetAnchorPoint( AnchorPoint::CENTER ); + controlLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + + Actor cancelButton = CreateCancelButton(); + cancelButton.SetParentOrigin( ParentOrigin::CENTER ); + cancelButton.SetAnchorPoint( AnchorPoint::CENTER ); + cancelButton.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS ); + cancelButton.SetSizeModeFactor( Vector3( -20.0f, -20.0f, 0.0 ) ); + + controlLayout.SetCellPadding( Size( 10.0f, 10.0f ) ); + + controlLayout.SetRelativeWidth( 0, 0.5f ); + controlLayout.SetRelativeWidth( 1, 0.5f ); + + controlLayout.SetCellAlignment( Toolkit::TableView::CellPosition( 0, 0 ), HorizontalAlignment::CENTER, VerticalAlignment::CENTER ); + controlLayout.SetCellAlignment( Toolkit::TableView::CellPosition( 0, 1 ), HorizontalAlignment::CENTER, VerticalAlignment::CENTER ); + controlLayout.AddChild( okButton, Toolkit::TableView::CellPosition( 0, 0 ) ); + controlLayout.AddChild( cancelButton, Toolkit::TableView::CellPosition( 0, 1 ) ); + + footer.Add( controlLayout ); + } + else + { + footer.Add( okButton ); + } + + confirmationPopup.SetFooter( footer ); + } + + confirmationPopup.OutsideTouchedSignal().Connect( this, &PopupExample::HidePopup ); + + return confirmationPopup; + } + + Actor CreateTitle( std::string title ) + { + Toolkit::TextLabel titleActor = Toolkit::TextLabel::New( title ); + titleActor.SetName( "title-actor" ); + titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); + titleActor.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); + titleActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + + return titleActor; + } + + Toolkit::PushButton CreateOKButton() + { + Toolkit::PushButton okayButton = Toolkit::PushButton::New(); + okayButton.SetName( POPUP_CONTROL_OK_NAME ); + okayButton.SetLabelText( "OK!" ); + + okayButton.ClickedSignal().Connect( this, &PopupExample::OnPopupButtonClicked ); + + return okayButton; + } + + Toolkit::PushButton CreateCancelButton() + { + Toolkit::PushButton cancelButton = Toolkit::PushButton::New(); + cancelButton.SetName( POPUP_CONTROL_CANCEL_NAME ); + cancelButton.SetLabelText( "Cancel" ); + + cancelButton.ClickedSignal().Connect( this, &PopupExample::OnPopupButtonClicked ); + + return cancelButton; + } + + bool OnPopupButtonClicked( Toolkit::Button button ) + { + // Handle Popup pushbuttons being clicked. + HidePopup(); + return true; + } + + bool OnButtonClicked( Toolkit::Button button ) + { + // Handle menu items that create popups. + if( button.GetName() == POPUP_BUTTON_TITLE_ID ) + { + mPopup = CreatePopup(); + mPopup.SetTitle( CreateTitle( "Popup!" ) ); + + SetupPopup( mPopup, button ); + } + else if( button.GetName() == POPUP_BUTTON_BUTTONS_1_ID ) + { + mPopup = CreateConfirmationPopup( 1 ); + mPopup.SetTitle( CreateTitle( "Title" ) ); + + SetupPopup( mPopup, button ); + } + else if( button.GetName() == POPUP_BUTTON_BUTTONS_2_ID ) + { + mPopup = CreateConfirmationPopup( 2 ); + mPopup.SetTitle( CreateTitle( "Title" ) ); + + SetupPopup( mPopup, button ); + } + else if( button.GetName() == POPUP_BUTTON_TOAST_ID ) + { + // Create a toast popup via the type registry (as it is a named-type). + TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "popup-toast" ); + if( typeInfo ) + { + BaseHandle baseHandle = typeInfo.CreateInstance(); + if( baseHandle ) + { + mPopup = Toolkit::Popup::DownCast( baseHandle ); + mPopup.SetTitle( CreateTitle( "This is a Toast Popup.\nIt will auto-hide itself" ) ); + + Stage::GetCurrent().Add( mPopup ); + mPopup.SetDisplayState( Toolkit::Popup::SHOWN ); + } + } + } + else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_BUTTONS_ID ) + { + mPopup = CreateConfirmationPopup( 2 ); + mPopup.SetTitle( CreateTitle( "Erase image" ) ); + + Toolkit::TextLabel text = Toolkit::TextLabel::New( "This will erase the image permanently. Are you sure?" ); + text.SetName( "POPUP_CONTENT_TEXT" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); + text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + text.SetProperty( TextLabel::Property::MULTI_LINE, true ); + text.SetPadding( Padding( 10.0f, 10.0f, 20.0f, 0.0f ) ); + mPopup.SetContent( text ); + + SetupPopup( mPopup, button ); + } + else if( button.GetName() == POPUP_BUTTON_CONTENT_TEXT_ID ) + { + mPopup = CreatePopup(); + + TextLabel text = TextLabel::New( CONTENT_TEXT ); + text.SetName( "POPUP_CONTENT_TEXT" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); + text.SetProperty( TextLabel::Property::MULTI_LINE, true ); + text.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + text.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); + text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) ); + + mPopup.Add( text ); + + SetupPopup( mPopup, button ); + } + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_ID ) + { + mPopup = CreatePopup(); + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) ); + image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + image.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + image.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) ); + + mPopup.Add( image ); + + SetupPopup( mPopup, button ); + } + else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_ID ) + { + mPopup = CreatePopup(); + mPopup.SetTitle( CreateTitle( "Popup!" ) ); + + Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT ); + text.SetName( "POPUP_CONTENT_TEXT" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); + text.SetProperty( TextLabel::Property::MULTI_LINE, true ); + text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) ); + + mPopup.Add( text ); + + SetupPopup( mPopup, button ); + } + else if( button.GetName() == POPUP_BUTTON_FIXED_SIZE_ID ) + { + mPopup = CreatePopup(); + mPopup.SetTitle( CreateTitle( "Popup!" ) ); + + Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed size popup" ); + text.SetName( "POPUP_CONTENT_TEXT" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); + text.SetProperty( TextLabel::Property::MULTI_LINE, true ); + text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) ); + + mPopup.Add( text ); + + // Fix the popup's size. + mPopup.SetSize( 240.0f, 400.0f ); + mPopup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); + + SetupPopup( mPopup, button ); + } + else if( button.GetName() == POPUP_BUTTON_TITLE_LARGE_CONTENT_BUTTONS_ID ) + { + mPopup = CreateConfirmationPopup( 2 ); + mPopup.SetTitle( CreateTitle( "Popup!" ) ); + + Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT ); + text.SetName( "POPUP_CONTENT_TEXT" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); + text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + text.SetProperty( TextLabel::Property::MULTI_LINE, true ); + text.SetPadding( Padding( 10.0f, 10.0f, 20.0f, 0.0f ) ); + + mPopup.Add( text ); + + SetupPopup( mPopup, button ); + } + else if( button.GetName() == POPUP_BUTTON_COMPLEX_ID ) + { + mPopup = CreateConfirmationPopup( 2 ); + mPopup.SetTitle( CreateTitle( "Warning" ) ); + + // Content + Toolkit::TableView content = Toolkit::TableView::New( 2, 2 ); + content.SetName( "COMPLEX_TABLEVIEW" ); + content.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + content.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); + content.SetFitHeight( 0 ); + content.SetFitHeight( 1 ); + content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) ); + + // Text + { + Toolkit::TextLabel text = Toolkit::TextLabel::New( "Do you really want to quit?" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); + text.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); + text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + + content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) ); + } + + // Image + { + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) ); + image.SetName( "COMPLEX_IMAGE" ); + image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + image.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) ); + content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) ); + } + + // Text 2 + { + Toolkit::TableView root = Toolkit::TableView::New( 1, 2 ); + root.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + root.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); + root.SetFitHeight( 0 ); + root.SetFitWidth( 0 ); + root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) ); + + Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New(); + checkBox.SetSize( 48, 48 ); + root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) ); + + Toolkit::TextLabel text = Toolkit::TextLabel::New( "Don't show again" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); + Actor textActor = text; + textActor.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) ); + + root.AddChild( text, Toolkit::TableView::CellPosition( 0, 1 ) ); + + content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0 ) ); + } + + mPopup.SetContent( content ); + + SetupPopup( mPopup, button ); + } + + return true; + } + + void OnKeyEvent( const KeyEvent& event ) + { + if( event.state == KeyEvent::Down ) + { + if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) + { + // Exit application when click back or escape. + mApplication.Quit(); + } + } + } + +public: // From ItemFactory + + /** + * @brief Return the number of items to display in the item view + * + * @return Return the number of items to display + */ + virtual unsigned int GetNumberOfItems() + { + return POPUP_BUTTON_ITEMS_COUNT; + } + + /** + * @brief Create a new item to populate the item view with + * + * @param[in] itemId The index of the item to create + * @return Return the created actor for the given ID + */ + virtual Actor NewItem(unsigned int itemId) + { + Toolkit::PushButton popupButton = Toolkit::PushButton::New(); + popupButton.SetName( POPUP_BUTTON_ITEMS[ itemId ].name ); + popupButton.SetLabelText( POPUP_BUTTON_ITEMS[ itemId ].text ); + popupButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); + + popupButton.ClickedSignal().Connect( this, &PopupExample::OnButtonClicked ); + + return popupButton; + } + +private: + + + Application& mApplication; + Toolkit::Control mView; ///< The View instance. + Toolkit::ToolBar mToolBar; ///< The View's Toolbar. + Toolkit::PushButton mContextButton; ///< For toggling contextual mode. + Toolkit::PushButton mAnimationButton; ///< For toggling the fade animation. + Layer mContentLayer; ///< Content layer + + Toolkit::TextLabel mTitleActor; ///< Title text + + bool mContextual; ///< True if currently using the contextual popup mode. + bool mAnimationFade; ///< True if currently using the fade animation. + + ResourceImage mContextButtonDisabledImage; ///< The disabled context button icon. + ResourceImage mContextButtonEnabledImage; ///< The enabled context button icon. + ResourceImage mAnimationButtonZoomImage; ///< The zoom animation button icon. + ResourceImage mAnimationButtonFadeImage; ///< The fade animation button icon. + + Toolkit::Popup mPopup; ///< The current example popup. + + Toolkit::ItemView mItemView; ///< ItemView to hold test images + +}; + +void RunTest( Application& application ) +{ + PopupExample test( application ); + + application.MainLoop(); +} + +// Entry point for Linux & SLP applications +int main( int argc, char **argv ) +{ + Application application = Application::New( &argc, &argv, DALI_DEMO_THEME_PATH ); + + RunTest( application ); + + return 0; +} diff --git a/examples/size-negotiation/size-negotiation-example.cpp b/examples/size-negotiation/size-negotiation-example.cpp index 6f6c926..fe292ca 100644 --- a/examples/size-negotiation/size-negotiation-example.cpp +++ b/examples/size-negotiation/size-negotiation-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -24,47 +24,22 @@ using namespace Dali; using Dali::Toolkit::TextLabel; -// Define this so that it is interchangeable -// "DP" stands for Device independent Pixels -#define DP(x) DemoHelper::ScalePointSize(x) - struct ButtonItem { const char* name; const char* text; }; - namespace { const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "background-gradient.jpg"; const char* const TOOLBAR_IMAGE = DALI_IMAGE_DIR "top-bar.png"; +const char* const IMAGE = DALI_IMAGE_DIR "background-magnifier.jpg"; const char* const TOOLBAR_TITLE = "Negotiate Size"; -const int TOOLBAR_HEIGHT = 62; - -const char* MENU_ICON_IMAGE = DALI_IMAGE_DIR "icon-cluster-none.png"; -const char* MENU_ICON_IMAGE_SELECTED = DALI_IMAGE_DIR "icon-cluster-none-selected.png"; -const char* const POPUPS_MENU_ID = "POPUPS_MENU"; -const char* const TABLEVIEW_MENU_ID = "TABLEVIEW_MENU"; - -const char* const POPUP_BUTTON_EMPTY_ID = "POPUP_BUTTON_EMPTY"; -const char* const POPUP_BUTTON_TITLE_ID = "POPUP_BUTTON_TITLE"; -const char* const POPUP_BUTTON_BUTTONS_1_ID = "POPUP_BUTTON_BUTTONS_1"; -const char* const POPUP_BUTTON_BUTTONS_2_ID = "POPUP_BUTTON_BUTTONS_2"; -const char* const POPUP_BUTTON_TITLE_BUTTONS_ID = "POPUP_BUTTON_TITLE_BUTTONS"; -const char* const POPUP_BUTTON_CONTENT_TEXT_ID = "POPUP_BUTTON_CONTENT_TEXT"; -const char* const POPUP_BUTTON_CONTENT_IMAGE_ID = "POPUP_BUTTON_CONTENT_IMAGE"; -const char* const POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID = "POPUP_BUTTON_CONTENT_IMAGE_SCALE"; -const char* const POPUP_BUTTON_CONTENT_IMAGE_FIT_ID = "POPUP_BUTTON_CONTENT_IMAGE_FIT"; -const char* const POPUP_BUTTON_CONTENT_IMAGE_FILL_ID = "POPUP_BUTTON_CONTENT_IMAGE_FILL"; -const char* const POPUP_BUTTON_TITLE_CONTENT_TEXT_ID = "POPUP_BUTTON_TITLE_CONTENT_TEXT"; -const char* const POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID = "POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS"; -const char* const POPUP_BUTTON_COMPLEX_ID = "POPUP_BUTTON_COMPLEX"; - -const char* const TABLEVIEW_BUTTON_EMPTY_ID = "TABLEVIEW_BUTTON_EMPTY"; +// This example contains size negotiation tests for TableView and Popup. const char* const TABLEVIEW_BUTTON_1CELL_ID = "TABLEVIEW_BUTTON_1CELL"; const char* const TABLEVIEW_BUTTON_3CELL_ID = "TABLEVIEW_BUTTON_3CELL"; const char* const TABLEVIEW_BUTTON_3X3CELL_ID = "TABLEVIEW_BUTTON_3X3CELL"; @@ -75,44 +50,11 @@ const char* const TABLEVIEW_BUTTON_FIT2_ID = "TABLEVIEW_BUTTON_FIT2"; const char* const TABLEVIEW_BUTTON_NATURAL1_ID = "TABLEVIEW_BUTTON_NATURAL1"; const char* const TABLEVIEW_BUTTON_NATURAL2_ID = "TABLEVIEW_BUTTON_NATURAL2"; const char* const TABLEVIEW_BUTTON_NATURAL3_ID = "TABLEVIEW_BUTTON_NATURAL3"; - -const char* const OKAY_BUTTON_ID = "OKAY_BUTTON"; -const char* const CANCEL_BUTTON_ID = "CANCEL_BUTTON"; - -const char* const CONTENT_TEXT = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; -const char* const IMAGE1 = DALI_IMAGE_DIR "gallery-medium-5.jpg"; -const char* const IMAGE2 = DALI_IMAGE_DIR "background-magnifier.jpg"; -const char* const CHECKBOX_UNCHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-unselected.png"; -const char* const CHECKBOX_CHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-selected.png"; - -const ButtonItem MENU_ITEMS[] = { - { POPUPS_MENU_ID, "Popups" }, - { TABLEVIEW_MENU_ID, "TableView" } -}; - -const unsigned int MENU_ITEMS_COUNT = sizeof( MENU_ITEMS ) / sizeof( MENU_ITEMS[0] ); - -const ButtonItem POPUP_BUTTON_ITEMS[] = { - { POPUP_BUTTON_COMPLEX_ID, "Complex" }, - { POPUP_BUTTON_EMPTY_ID, "Empty" }, - { POPUP_BUTTON_TITLE_ID, "Title" }, - { POPUP_BUTTON_BUTTONS_1_ID, "1 Button" }, - { POPUP_BUTTON_BUTTONS_2_ID, "2 Buttons" }, - { POPUP_BUTTON_TITLE_BUTTONS_ID, "Title & Buttons" }, - { POPUP_BUTTON_CONTENT_TEXT_ID, "Text" }, - { POPUP_BUTTON_CONTENT_IMAGE_ID, "Image" }, - { POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID, "Image Scale" }, - { POPUP_BUTTON_CONTENT_IMAGE_FIT_ID, "Image Fit" }, - { POPUP_BUTTON_CONTENT_IMAGE_FILL_ID, "Image Fill" }, - { POPUP_BUTTON_TITLE_CONTENT_TEXT_ID, "Title Text" }, - { POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID, "Title, text, buttons" } - -}; - -const int POPUP_BUTTON_ITEMS_COUNT = sizeof( POPUP_BUTTON_ITEMS ) / sizeof( POPUP_BUTTON_ITEMS[0] ); +const char* const POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID = "POPUP_BUTTON_CONTENT_IMAGE_SCALE"; +const char* const POPUP_BUTTON_CONTENT_IMAGE_FIT_ID = "POPUP_BUTTON_CONTENT_IMAGE_FIT"; +const char* const POPUP_BUTTON_CONTENT_IMAGE_FILL_ID = "POPUP_BUTTON_CONTENT_IMAGE_FILL"; const ButtonItem TABLEVIEW_BUTTON_ITEMS[] = { - { TABLEVIEW_BUTTON_EMPTY_ID, "Empty" }, { TABLEVIEW_BUTTON_1CELL_ID, "1 Cell" }, { TABLEVIEW_BUTTON_3CELL_ID, "3 Cell" }, { TABLEVIEW_BUTTON_3X3CELL_ID, "3x3 Cells" }, @@ -123,12 +65,14 @@ const ButtonItem TABLEVIEW_BUTTON_ITEMS[] = { { TABLEVIEW_BUTTON_NATURAL1_ID, "Natural 1" }, { TABLEVIEW_BUTTON_NATURAL2_ID, "Natural 2" }, { TABLEVIEW_BUTTON_NATURAL3_ID, "Natural 3" }, + { POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID, "Image Scale" }, + { POPUP_BUTTON_CONTENT_IMAGE_FIT_ID, "Image Fit" }, + { POPUP_BUTTON_CONTENT_IMAGE_FILL_ID, "Image Fill" }, }; const unsigned int TABLEVIEW_BUTTON_ITEMS_COUNT = sizeof( TABLEVIEW_BUTTON_ITEMS ) / sizeof( TABLEVIEW_BUTTON_ITEMS[0] ); -} // namespace - +} // anonymous namespace /** @@ -139,9 +83,7 @@ class SizeNegotiationController: public ConnectionTracker, public Toolkit::ItemF public: SizeNegotiationController( Application& application ) - : mApplication( application ), - mMenuShown( false ), - mDemoState( POPUP ) + : mApplication( application ) { // Connect to the Application's Init signal mApplication.InitSignal().Connect( this, &SizeNegotiationController::Create ); @@ -155,7 +97,6 @@ public: void Create( Application& application ) { // The Init signal is received once (only) during the Application lifetime - Stage stage = Stage::GetCurrent(); // Respond to key events @@ -171,15 +112,7 @@ public: std::string("") ); mTitleActor = DemoHelper::CreateToolBarLabel( "CUSTOM_TOOLBAR_TITLE" ); - - SetTitle(); - - // Create menu button - Toolkit::PushButton viewButton = Toolkit::PushButton::New(); - viewButton.SetUnselectedImage( MENU_ICON_IMAGE ); - viewButton.SetSelectedImage( MENU_ICON_IMAGE_SELECTED ); - viewButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnMenu ); - mToolBar.AddControl( viewButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); + mTitleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, TOOLBAR_TITLE ); // Add title to the tool bar. const float padding( DemoHelper::DEFAULT_VIEW_STYLE.mToolBarPadding ); @@ -204,116 +137,27 @@ public: mContentLayer.Add( mItemView ); } - void SetTitle() - { - std::string subTitle = ""; - - switch( mDemoState ) - { - case POPUP: - { - subTitle = "Popups"; - break; - } - - case TABLEVIEW: - { - subTitle = "TableView"; - break; - } - - default: - { - break; - } - } - - mTitleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, std::string( std::string( TOOLBAR_TITLE ) + ": " + subTitle ) ); - } - - bool OnMenu( Toolkit::Button button ) + void StagePopup( Toolkit::Popup popup ) { - ShowMenu(); - return true; - } - - void ShowMenu() - { - Stage stage = Stage::GetCurrent(); - const float popupWidth = stage.GetSize().x * 0.5f; - - mMenu = Toolkit::Popup::New(); - mMenu.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mMenu.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mMenu.HideTail(); - mMenu.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::HideMenu ); - mMenu.SetSize( popupWidth, 0.0f ); - mMenu.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); - - Toolkit::TableView tableView = Toolkit::TableView::New( 0, 0 ); - tableView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - tableView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); - mMenu.Add( tableView ); - - for( unsigned int i = 0; i < MENU_ITEMS_COUNT; ++i ) - { - Toolkit::PushButton menuButton = Toolkit::PushButton::New(); - menuButton.SetName( MENU_ITEMS[ i ].name ); - menuButton.SetLabelText( MENU_ITEMS[ i ].text ); - menuButton.SetUnselectedImage( "" ); - menuButton.SetSelectedImage( "" ); - menuButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnMenuSelect ); - - tableView.Add( menuButton ); - tableView.SetFitHeight( i ); - } - - // Show the menu - mMenu.Show(); - mMenuShown = true; + Stage::GetCurrent().Add( popup ); + popup.SetDisplayState( Toolkit::Popup::SHOWN ); } - void HideMenu() + void OnPopupOutsideTouched() { - if( mMenu ) + if( mPopup ) { - mMenu.Hide(); - mMenu.Reset(); + mPopup.SetDisplayState( Toolkit::Popup::HIDDEN ); } - - mMenuShown = false; } - bool OnMenuSelect( Toolkit::Button button ) + void PopupHidden() { - bool refresh = false; - - if( button.GetName() == POPUPS_MENU_ID ) - { - if( mDemoState != POPUP ) - { - refresh = true; - mDemoState = POPUP; - } - } - else if( button.GetName() == TABLEVIEW_MENU_ID ) - { - if( mDemoState != TABLEVIEW ) - { - refresh = true; - mDemoState = TABLEVIEW; - } - } - - if( refresh ) + if( mPopup ) { - SetTitle(); - - mItemView.Refresh(); + mPopup.Unparent(); + mPopup.Reset(); } - - HideMenu(); - return true; } Toolkit::Popup CreatePopup() @@ -322,312 +166,26 @@ public: const float POPUP_WIDTH_DP = stage.GetSize().width * 0.75f; Toolkit::Popup popup = Toolkit::Popup::New(); - popup.SetName( "POPUP" ); + popup.SetName( "popup" ); popup.SetParentOrigin( ParentOrigin::CENTER ); popup.SetAnchorPoint( AnchorPoint::CENTER ); popup.SetSize( POPUP_WIDTH_DP, 0.0f ); - popup.HideTail(); + popup.SetProperty( Toolkit::Popup::Property::TAIL_VISIBILITY, false ); popup.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::OnPopupOutsideTouched ); + popup.HiddenSignal().Connect( this, &SizeNegotiationController::PopupHidden ); return popup; } bool OnButtonClicked( Toolkit::Button button ) { - if( button.GetName() == POPUP_BUTTON_EMPTY_ID ) - { - mPopup = CreatePopup(); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_TITLE_ID ) - { - mPopup = CreatePopup(); - mPopup.SetTitle( "Popup!" ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_BUTTONS_1_ID ) - { - mPopup = CreatePopup(); - - Toolkit::PushButton okayButton = Toolkit::PushButton::New(); - okayButton.SetName( OKAY_BUTTON_ID ); - okayButton.SetLabelText( "OK!" ); - - okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - - mPopup.AddButton( okayButton ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_BUTTONS_2_ID ) - { - mPopup = CreatePopup(); - - Toolkit::PushButton cancelButton = Toolkit::PushButton::New(); - cancelButton.SetName( CANCEL_BUTTON_ID ); - cancelButton.SetLabelText( "Cancel" ); - - cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - - mPopup.AddButton( cancelButton ); - - Toolkit::PushButton okayButton = Toolkit::PushButton::New(); - okayButton.SetName( OKAY_BUTTON_ID ); - okayButton.SetLabelText( "OK!" ); - - okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - - mPopup.AddButton( okayButton ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_TITLE_BUTTONS_ID ) - { - mPopup = CreatePopup(); - mPopup.SetTitle( "Popup!" ); - - Toolkit::PushButton cancelButton = Toolkit::PushButton::New(); - cancelButton.SetName( CANCEL_BUTTON_ID ); - cancelButton.SetLabelText( "Cancel" ); - - cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - - mPopup.AddButton( cancelButton ); - - Toolkit::PushButton okayButton = Toolkit::PushButton::New(); - okayButton.SetName( OKAY_BUTTON_ID ); - okayButton.SetLabelText( "OK!" ); - - okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - - mPopup.AddButton( okayButton ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_CONTENT_TEXT_ID ) - { - mPopup = CreatePopup(); - - TextLabel text = TextLabel::New( CONTENT_TEXT ); - text.SetName( "POPUP_CONTENT_TEXT" ); - text.SetProperty( TextLabel::Property::MULTI_LINE, true ); - text.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); - text.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); - text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); - text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) ); - - mPopup.Add( text ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_ID ) - { - mPopup = CreatePopup(); - - Toolkit::ImageView image = Toolkit::ImageView::New( IMAGE2 ); - image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - image.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); - image.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) ); - - mPopup.Add( image ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID ) - { - mPopup = CreatePopup(); - - mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - - Toolkit::ImageView image = Toolkit::ImageView::New( IMAGE2 ); - image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - mPopup.Add( image ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID ) - { - mPopup = CreatePopup(); - - mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - - Toolkit::ImageView image = Toolkit::ImageView::New( IMAGE2 ); - image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - image.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); - - mPopup.Add( image ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID ) + if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID ) { mPopup = CreatePopup(); - mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - Toolkit::ImageView image = Toolkit::ImageView::New( IMAGE2 ); - image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - image.SetSizeScalePolicy( SizeScalePolicy::FILL_WITH_ASPECT_RATIO ); - - mPopup.Add( image ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_ID ) - { - mPopup = CreatePopup(); - mPopup.SetTitle( "Popup!" ); - - Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT ); - text.SetName( "POPUP_CONTENT_TEXT" ); - text.SetProperty( TextLabel::Property::MULTI_LINE, true ); - text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); - text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) ); - - mPopup.Add( text ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID ) - { - mPopup = CreatePopup(); - mPopup.SetTitle( "Popup!" ); - - Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT ); - text.SetName( "POPUP_CONTENT_TEXT" ); - text.SetProperty( TextLabel::Property::MULTI_LINE, true ); - text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); - text.SetPadding( Padding( 10.0f, 10.0f, 20.0f, 0.0f ) ); - - mPopup.Add( text ); - - Toolkit::PushButton cancelButton = Toolkit::PushButton::New(); - cancelButton.SetName( CANCEL_BUTTON_ID ); - cancelButton.SetLabelText( "Cancel" ); - - cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - - mPopup.AddButton( cancelButton ); - - Toolkit::PushButton okayButton = Toolkit::PushButton::New(); - okayButton.SetName( OKAY_BUTTON_ID ); - okayButton.SetLabelText( "OK!" ); - - okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - - mPopup.AddButton( okayButton ); - - mPopup.Show(); - } - else if( button.GetName() == POPUP_BUTTON_COMPLEX_ID ) - { - mPopup = CreatePopup(); - mPopup.SetTitle( "Warning" ); - - // Content - Toolkit::TableView content = Toolkit::TableView::New( 2, 2 ); - content.SetName( "COMPLEX_TABLEVIEW" ); - content.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - content.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); - content.SetFitHeight( 0 ); - content.SetFitHeight( 1 ); - content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) ); - - // Text - { - Toolkit::TextLabel text = Toolkit::TextLabel::New( "Do you really want to quit?" ); - text.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); - text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); - - content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) ); - } - - // Image - { - Toolkit::ImageView image = Toolkit::ImageView::New( IMAGE1 ); - image.SetName( "COMPLEX_IMAGE" ); - image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - image.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); - image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) ); - content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) ); - } - - // Text 2 - { - Toolkit::TableView root = Toolkit::TableView::New( 1, 2 ); - root.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - root.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); - root.SetFitHeight( 0 ); - root.SetFitWidth( 0 ); - root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) ); - - Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New(); - checkBox.SetSize( 48, 48 ); - - root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) ); - - Toolkit::TextLabel text = Toolkit::TextLabel::New( "Don't show again" ); - Actor textActor = text; - textActor.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) ); - - root.AddChild( text, Toolkit::TableView::CellPosition( 0, 1 ) ); - - content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0 ) ); - } - - mPopup.Add( content ); - - // Buttons - Toolkit::PushButton cancelButton = Toolkit::PushButton::New(); - cancelButton.SetName( CANCEL_BUTTON_ID ); - cancelButton.SetLabelText( "Cancel" ); - - cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - - mPopup.AddButton( cancelButton ); - - Toolkit::PushButton okayButton = Toolkit::PushButton::New(); - okayButton.SetName( OKAY_BUTTON_ID ); - okayButton.SetLabelText( "OK!" ); - - okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - - mPopup.AddButton( okayButton ); - - mPopup.Show(); - } - else if( button.GetName() == TABLEVIEW_BUTTON_EMPTY_ID ) - { - mPopup = CreatePopup(); - mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - - - Toolkit::TableView table = Toolkit::TableView::New( 0, 0 ); - table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - mPopup.Add( table ); - - mPopup.Show(); - } - else if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID ) - { - mPopup = CreatePopup(); - mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - - Toolkit::TableView table = Toolkit::TableView::New( 0, 0 ); table.SetName( "TABLEVIEW_BUTTON_1CELL_ID" ); table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -638,7 +196,7 @@ public: mPopup.Add( table ); - mPopup.Show(); + StagePopup( mPopup ); } else if( button.GetName() == TABLEVIEW_BUTTON_3CELL_ID ) { @@ -646,29 +204,28 @@ public: mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - - Toolkit::TableView table = Toolkit::TableView::New( 0, 0 ); + Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); { Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - table.Add( backing ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 0 ) ); } { Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - table.Add( backing ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 0 ) ); } { Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - table.Add( backing ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 0 ) ); } - mPopup.Add( table ); + mPopup.SetContent( table ); - mPopup.Show(); + StagePopup( mPopup ); } else if( button.GetName() == TABLEVIEW_BUTTON_3X3CELL_ID ) { @@ -676,7 +233,6 @@ public: mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - Toolkit::TableView table = Toolkit::TableView::New( 3, 3 ); table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -733,7 +289,7 @@ public: mPopup.Add( table ); - mPopup.Show(); + StagePopup( mPopup ); } else if( button.GetName() == TABLEVIEW_BUTTON_FIXED1_ID ) { @@ -741,7 +297,6 @@ public: mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); table.SetFixedHeight( 0, 50.0f ); @@ -750,6 +305,7 @@ public: Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); @@ -761,6 +317,7 @@ public: Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); @@ -772,6 +329,7 @@ public: Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); @@ -782,7 +340,7 @@ public: mPopup.Add( table ); - mPopup.Show(); + StagePopup( mPopup ); } else if( button.GetName() == TABLEVIEW_BUTTON_FIXED2_ID ) { @@ -790,7 +348,6 @@ public: mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); table.SetFixedHeight( 0, 50.0f ); @@ -800,6 +357,7 @@ public: Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -813,6 +371,7 @@ public: Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -826,6 +385,7 @@ public: Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -838,7 +398,7 @@ public: mPopup.Add( table ); - mPopup.Show(); + StagePopup( mPopup ); } else if( button.GetName() == TABLEVIEW_BUTTON_FIT1_ID ) { @@ -846,7 +406,6 @@ public: mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); table.SetFitHeight( 0 ); @@ -858,6 +417,7 @@ public: backing.SetSize( 0.0f, 100.0f ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -873,6 +433,7 @@ public: backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -889,6 +450,7 @@ public: backing.SetSize( 0.0f, 100.0f ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -902,7 +464,7 @@ public: mPopup.Add( table ); - mPopup.Show(); + StagePopup( mPopup ); } else if( button.GetName() == TABLEVIEW_BUTTON_FIT2_ID ) { @@ -919,6 +481,7 @@ public: backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -935,6 +498,7 @@ public: backing.SetSize( 0.0f, 200.0f ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); @@ -950,6 +514,7 @@ public: backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -963,7 +528,7 @@ public: mPopup.Add( table ); - mPopup.Show(); + StagePopup( mPopup ); } else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL1_ID ) { @@ -985,6 +550,7 @@ public: backing.SetSize( 0.0f, 100.0f ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -1001,6 +567,7 @@ public: backing.SetSize( 0.0f, 200.0f ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -1017,6 +584,7 @@ public: backing.SetSize( 0.0f, 300.0f ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -1030,7 +598,7 @@ public: mPopup.Add( table ); - mPopup.Show(); + StagePopup( mPopup ); } else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL2_ID ) { @@ -1052,6 +620,7 @@ public: backing.SetSize( 0.0f, 100.0f ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -1068,6 +637,7 @@ public: backing.SetSize( 0.0f, 200.0f ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -1081,7 +651,7 @@ public: mPopup.Add( table ); - mPopup.Show(); + StagePopup( mPopup ); } else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL3_ID ) { @@ -1101,6 +671,7 @@ public: backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -1117,6 +688,7 @@ public: backing.SetSize( 0.0f, 200.0f ); Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" ); + text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); text.SetAnchorPoint( AnchorPoint::CENTER ); text.SetParentOrigin( ParentOrigin::CENTER ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -1127,28 +699,53 @@ public: table.Add( backing ); } - mPopup.Add( table ); - mPopup.Show(); + StagePopup( mPopup ); } - else if( button.GetName() == OKAY_BUTTON_ID || button.GetName() == CANCEL_BUTTON_ID ) + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID ) { - if( mPopup ) - { - mPopup.Hide(); - } + mPopup = CreatePopup(); + mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE ) ); + image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + + mPopup.Add( image ); + + StagePopup( mPopup ); } + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); - return true; - } + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE ) ); + image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + image.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); - void OnPopupOutsideTouched() - { - if( mPopup ) + mPopup.Add( image ); + + StagePopup( mPopup ); + } + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID ) { - mPopup.Hide(); + mPopup = CreatePopup(); + mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE ) ); + image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + image.SetSizeScalePolicy( SizeScalePolicy::FILL_WITH_ASPECT_RATIO ); + + mPopup.Add( image ); + + StagePopup( mPopup ); } + + return true; } void OnKeyEvent( const KeyEvent& event ) @@ -1172,25 +769,7 @@ public: // From ItemFactory */ virtual unsigned int GetNumberOfItems() { - switch( mDemoState ) - { - case POPUP: - { - return POPUP_BUTTON_ITEMS_COUNT; - } - - case TABLEVIEW: - { - return TABLEVIEW_BUTTON_ITEMS_COUNT; - } - - default: - { - break; - } - } - - return 0; + return TABLEVIEW_BUTTON_ITEMS_COUNT; } /** @@ -1201,65 +780,29 @@ public: // From ItemFactory */ virtual Actor NewItem(unsigned int itemId) { - const ButtonItem* buttonDataArray = NULL; - switch( mDemoState ) - { - case POPUP: - { - buttonDataArray = POPUP_BUTTON_ITEMS; - break; - } + Toolkit::PushButton popupButton = Toolkit::PushButton::New(); + popupButton.SetName( TABLEVIEW_BUTTON_ITEMS[ itemId ].name ); + popupButton.SetLabelText( TABLEVIEW_BUTTON_ITEMS[ itemId ].text ); + popupButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); - case TABLEVIEW: - { - buttonDataArray = TABLEVIEW_BUTTON_ITEMS; - break; - } + popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - default: - { - break; - } - } - - if( buttonDataArray ) - { - Toolkit::PushButton popupButton = Toolkit::PushButton::New(); - popupButton.SetName( buttonDataArray[ itemId ].name ); - popupButton.SetLabelText( buttonDataArray[ itemId ].text ); - popupButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); - - popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); - - return popupButton; - } - - return Actor(); + return popupButton; } private: - enum DemoState - { - POPUP, - TABLEVIEW - }; - - Application& mApplication; - Toolkit::Control mView; ///< The View instance. - Toolkit::ToolBar mToolBar; ///< The View's Toolbar. - Layer mContentLayer; ///< Content layer - - Toolkit::TextLabel mTitleActor; ///< Title text - - Toolkit::Popup mMenu; ///< The navigation menu - bool mMenuShown; ///< If the navigation menu is currently being displayed or not + Application& mApplication; + Toolkit::Control mView; ///< The View instance. + Toolkit::ToolBar mToolBar; ///< The View's Toolbar. + Layer mContentLayer; ///< Content layer. - Toolkit::Popup mPopup; + Toolkit::TextLabel mTitleActor; ///< Title text. + Toolkit::Popup mMenu; ///< The navigation menu todor. + Toolkit::Popup mPopup; ///< The current example popup. - Toolkit::ItemView mItemView; ///< ItemView to hold test images + Toolkit::ItemView mItemView; ///< ItemView to hold test images. - DemoState mDemoState; }; void RunTest( Application& application ) @@ -1270,7 +813,6 @@ void RunTest( Application& application ) } // Entry point for Linux & SLP applications -// int main( int argc, char **argv ) { Application application = Application::New( &argc, &argv, DALI_DEMO_THEME_PATH ); diff --git a/examples/text-field/text-field-example.cpp b/examples/text-field/text-field-example.cpp index eae9fa1..2f8c283 100644 --- a/examples/text-field/text-field-example.cpp +++ b/examples/text-field/text-field-example.cpp @@ -106,7 +106,7 @@ public: mPopup = CreatePopup( stageSize.width * 0.8f ); mPopup.Add( mField ); mPopup.OutsideTouchedSignal().Connect( this, &TextFieldExample::OnPopupOutsideTouched ); - mPopup.Show(); + mPopup.SetDisplayState( Popup::SHOWN ); return true; } @@ -133,7 +133,6 @@ public: popup.SetParentOrigin( ParentOrigin::CENTER ); popup.SetAnchorPoint( AnchorPoint::CENTER ); popup.SetSize( width, 0.0f ); - popup.HideTail(); popup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); popup.SetSizeModeFactor( POPUP_SIZE_FACTOR_TO_PARENT ); popup.TouchedSignal().Connect( this, &TextFieldExample::OnPopupTouched ); @@ -154,7 +153,7 @@ public: // Hide & discard the pop-up if( mPopup ) { - mPopup.Hide(); + mPopup.SetDisplayState( Popup::HIDDEN ); } mField.Reset(); } diff --git a/resources/images/popup_button_background.png b/resources/images/popup_button_background.png new file mode 100644 index 0000000000000000000000000000000000000000..10c746648ca07f5df707b3d074060b28c33da428 GIT binary patch literal 2975 zcmV;Q3t;q#P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0002WNkl`f!qK9 literal 0 HcmV?d00001 diff --git a/resources/scripts/popup.json b/resources/scripts/popup.json new file mode 100644 index 0000000..70a2eef --- /dev/null +++ b/resources/scripts/popup.json @@ -0,0 +1,316 @@ +{ + "constants": { + "CONFIG_SCRIPT_LOG_LEVEL": "Verbose" + }, + "stage": [ + { + "type": "ConfirmationPopup", + "name": "confirmation-popup", + "parent-origin": [0.5, 0.55, 0.5], + "anchor-point": "CENTER", + "width-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "height-resize-policy": "USE_NATURAL_SIZE", + "size-mode-factor": [0.65, 1.0, 1.0], + "tail-visibility": false, + "tail-position": [0, 0, 0], + "display-change-animation-duration": 1.0, + "contextual-mode": "NON_CONTEXTUAL", + "animation-mode": "ZOOM", + "control-ok": "control-ok", + "control-cancel": "control-cancel", + "connect-signal-ok-selected": "clicked", + "connect-signal-cancel-selected": "clicked", + "title": { + "type": "TextLabel", + "text": "Title text", + "text-color": [1, 1, 1, 1] + }, + "content": { + "type": "TextLabel", + "text": "Content text", + "padding": [20, 20, 20, 0], + "text-color": [1, 1, 1, 1] + }, + "footer": { + "type": "Control", + "size": [0, 80, 0], + "width-resize-policy": "FILL_TO_PARENT", + "height-resize-policy": "FIXED", + "parent-origin": "CENTER", + "anchor-point": "CENTER", + "actors": [ + { + "type": "PushButton", + "name": "control-ok", + "parent-origin": "CENTER_LEFT", + "anchor-point": "CENTER_LEFT", + "position": [20, 0, 0], + "label-text": "OK" + }, + { + "type": "PushButton", + "name": "control-cancel", + "parent-origin": "CENTER_RIGHT", + "anchor-point": "CENTER_RIGHT", + "position": [-20, 0, 0], + "label-text": "Cancel" + } + ] + }, + "signals": [ + { + "name": "control-signal-ok", + "action": "set", + "actor": "selection-label", + "property": "text", + "value": "User pressed: OK Button" + }, + { + "name": "control-signal-ok", + "action": "set", + "actor": "confirmation-popup", + "property": "display-state", + "value": "HIDDEN" + }, + { + "name": "control-signal-cancel", + "action": "set", + "actor": "selection-label", + "property": "text", + "value": "User pressed: Cancel Button" + }, + { + "name": "control-signal-cancel", + "action": "set", + "actor": "confirmation-popup", + "property": "display-state", + "value": "HIDDEN" + }, + { + "name": "touched-outside", + "action": "set", + "actor": "confirmation-popup", + "property": "display-state", + "value": "HIDDEN" + }, + { + "name": "touched-outside", + "action": "set", + "actor": "selection-label", + "property": "text", + "value": "No button pressed, backing touched" + } + ] + }, + { + "type": "ConfirmationPopup", + "name": "custom-animation-popup", + "parent-origin": [0.5, 0.55, 0.5], + "anchor-point": "CENTER", + "width-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "height-resize-policy": "USE_NATURAL_SIZE", + "size-mode-factor": [0.65, 1.0, 1.0], + "tail-visible": false, + "tail-position": [0, 0, 0], + "display-change-animation-duration": 1.0, + "contextual-mode": "NON_CONTEXTUAL", + "control-ok": "control-ok", + "control-cancel": "control-cancel", + "connect-signal-ok-selected": "clicked", + "connect-signal-cancel-selected": "clicked", + "animation-mode": "CUSTOM", + "entry-animation": { + "actor": "custom-animation-popup", + "property": "position", + "value": [ + 0, + 0, + 0 + ], + "alpha-function": "EASE_OUT", + "time-period": { + "delay": 0.0, + "duration": 1.0 + } + }, + "exit-animation": { + "actor": "custom-animation-popup", + "property": "position", + "value": [ + -450, + -225, + 0 + ], + "alpha-function": "EASE_IN", + "time-period": { + "delay": 0.0, + "duration": 1.0 + } + }, + "title": { + "type": "TextLabel", + "text": "Title text", + "text-color": [1, 1, 1, 1] + }, + "content": { + "type": "TextLabel", + "text": "Content text", + "padding": [20, 20, 20, 0], + "text-color": [1, 1, 1, 1] + }, + "footer": { + "type": "Control", + "size": [0, 80, 0], + "width-resize-policy": "FILL_TO_PARENT", + "height-resize-policy": "FIXED", + "parent-origin": "CENTER", + "anchor-point": "CENTER", + "actors": [ + { + "type": "PushButton", + "name": "control-ok", + "parent-origin": "CENTER_LEFT", + "anchor-point": "CENTER_LEFT", + "position": [20, 0, 0], + "label-text": "OK" + }, + { + "type": "PushButton", + "name": "control-cancel", + "parent-origin": "CENTER_RIGHT", + "anchor-point": "CENTER_RIGHT", + "position": [-20, 0, 0], + "label-text": "Cancel" + } + ] + }, + "signals": [ + { + "name": "control-signal-ok", + "action": "set", + "actor": "selection-label", + "property": "text", + "value": "User pressed: OK Button" + }, + { + "name": "control-signal-ok", + "action": "set", + "actor": "custom-animation-popup", + "property": "display-state", + "value": "HIDDEN" + }, + { + "name": "control-signal-cancel", + "action": "set", + "actor": "selection-label", + "property": "text", + "value": "User pressed: Cancel Button" + }, + { + "name": "control-signal-cancel", + "action": "set", + "actor": "custom-animation-popup", + "property": "display-state", + "value": "HIDDEN" + }, + { + "name": "touched-outside", + "action": "set", + "actor": "custom-animation-popup", + "property": "display-state", + "value": "HIDDEN" + }, + { + "name": "touched-outside", + "action": "set", + "actor": "selection-label", + "property": "text", + "value": "No button pressed, backing touched" + } + ] + }, + { + "type": "popup-toast", + "name": "toast", + "width-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "height-resize-policy": "USE_NATURAL_SIZE", + "size-mode-factor": [0.85, 0, 0], + "title": { + "type": "TextLabel", + "width-resize-policy": "FILL_TO_PARENT", + "height-resize-policy": "USE_NATURAL_SIZE", + "parent-origin": "CENTER", + "anchor-point": "CENTER", + "text": "This is a toast popup. \nIt will auto-hide itself.", + "text-color": [1, 1, 1, 1], + "multi-line": true, + "horizontal-alignment": "CENTER", + "vertical-alignment": "CENTER", + "padding": [20.0, 20.0, 20.0, 20.0] + } + }, + { + "type": "PushButton", + "name": "popup-trigger-button", + "parent-origin": [0.1, 0.1, 0.5], + "anchor-point": "TOP_LEFT", + "width-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "height-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "size-mode-factor": [0.38, 0.14, 1.0], + "label-text": "Popup", + "signals": [{ + "name": "clicked", + "action": "set", + "actor": "confirmation-popup", + "property": "display-state", + "value": "SHOWN" + }] + }, + { + "type": "PushButton", + "name": "animated-popup-trigger-button", + "parent-origin": [0.9, 0.1, 0.5], + "anchor-point": "TOP_RIGHT", + "width-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "height-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "size-mode-factor": [0.38, 0.14, 1.0], + "label-text": "Animated", + "signals": [{ + "name": "clicked", + "action": "set", + "actor": "custom-animation-popup", + "property": "display-state", + "value": "SHOWN" + }] + }, + { + "type": "PushButton", + "name": "toast-trigger-button", + "parent-origin": [0.5, 1.0, 0.5], + "anchor-point": "BOTTOM_CENTER", + "width-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "height-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "size-mode-factor": [0.5, 0.14, 1.0], + "label-text": "Push for Toast", + "signals": [{ + "name": "clicked", + "action": "set", + "actor": "toast", + "property": "display-state", + "value": "SHOWN" + }] + }, + { + "type": "TextLabel", + "name": "selection-label", + "parent-origin": [0.5, 0.22, 0.5], + "anchor-point": "TOP_CENTER", + "width-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "height-resize-policy": "SIZE_RELATIVE_TO_PARENT", + "size-mode-factor": [0.9, 0.14, 1.0], + "text": "No selection made", + "horizontal-alignment": "CENTER", + "vertical-alignment": "CENTER" + } + ] +} diff --git a/resources/scripts/super-blur-view.json b/resources/scripts/super-blur-view.json index a94252c..c786b47 100644 --- a/resources/scripts/super-blur-view.json +++ b/resources/scripts/super-blur-view.json @@ -70,8 +70,8 @@ "type": "TextLabel", "text": "Blur" }, - "unselected-state-actor": "{DALI_IMAGE_DIR}button-background.png", - "selected-state-actor": "{DALI_IMAGE_DIR}button-background.png", + "unselected-state-image": "{DALI_IMAGE_DIR}button-background.png", + "selected-state-image": "{DALI_IMAGE_DIR}button-background.png", "signals": [{ "name": "pressed", "action": "play", diff --git a/shared/dali-demo-strings.h b/shared/dali-demo-strings.h index d6b01a9..f7ab480 100644 --- a/shared/dali-demo-strings.h +++ b/shared/dali-demo-strings.h @@ -53,7 +53,8 @@ extern "C" #define DALI_DEMO_STR_TITLE_TEXT_LABEL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_LABEL") #define DALI_DEMO_STR_TITLE_TEXT_LABEL_MULTI_LANGUAGE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_LABEL_MULTI_LANGUAGE") #define DALI_DEMO_STR_TITLE_EMOJI_TEXT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_EMOJI_TEXT") -#define DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE dgettext(DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE) +#define DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE") +#define DALI_DEMO_STR_TITLE_POPUP dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_POPUP") #define DALI_DEMO_STR_TITLE_BUTTONS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BUTTONS") #define DALI_DEMO_STR_TITLE_LOGGING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_LOGGING") #define DALI_DEMO_STR_TITLE_MESH_MORPH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_MESH_MORPH") @@ -85,6 +86,7 @@ extern "C" #define DALI_DEMO_STR_TITLE_TEXT_LABEL_MULTI_LANGUAGE "Text Scripts" #define DALI_DEMO_STR_TITLE_EMOJI_TEXT "Emoji Text" #define DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE "Negotiate Size" +#define DALI_DEMO_STR_TITLE_POPUP "Popup" #define DALI_DEMO_STR_TITLE_BUTTONS "Buttons" #define DALI_DEMO_STR_TITLE_LOGGING "Logging" #define DALI_DEMO_STR_TITLE_MESH_MORPH "Mesh Morph" -- 2.7.4