[dali_1.1.42] Merge branch 'devel/master'
[platform/core/uifw/dali-demo.git] / examples / popup / popup-example.cpp
index ea2e89a..b79bccc 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/dali.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/popup/popup.h>
+#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
 
 using namespace Dali;
 
@@ -33,15 +34,15 @@ struct ButtonItem
 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 BACKGROUND_IMAGE = DEMO_IMAGE_DIR "background-gradient.jpg";
+const char* const TOOLBAR_IMAGE = DEMO_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* CONTEXT_DISABLED_ICON_IMAGE = DEMO_IMAGE_DIR "icon-scroll-view-carousel.png";
+const char* CONTEXT_ENABLED_ICON_IMAGE = DEMO_IMAGE_DIR "icon-scroll-view-spiral.png";
+const char* ANIMATION_FADE_ICON_IMAGE = DEMO_IMAGE_DIR "icon-effects-off.png";
+const char* ANIMATION_ZOOM_ICON_IMAGE = DEMO_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";
@@ -56,15 +57,15 @@ 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 POPUP_CONTROL_OK_NAME = "controlOk";
+const char* const POPUP_CONTROL_CANCEL_NAME = "controlCancel";
 
 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 IMAGE1 = DEMO_IMAGE_DIR "gallery-medium-5.jpg";
+const char* const IMAGE2 = DEMO_IMAGE_DIR "background-magnifier.jpg";
 
 // Control area image.
-const char*   DEFAULT_CONTROL_AREA_IMAGE_PATH = DALI_IMAGE_DIR "popup_button_background.9.png"; ///< Control area image for the popup.
+const char*   DEFAULT_CONTROL_AREA_IMAGE_PATH = DEMO_IMAGE_DIR "popup_button_background.9.png"; ///< Control area image for the popup.
 
 const ButtonItem POPUP_BUTTON_ITEMS[] = {
     { POPUP_BUTTON_COMPLEX_ID,                     "Complex" },
@@ -111,8 +112,12 @@ public:
     // 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);
+    // Respond to key events if not handled
+    Toolkit::KeyInputFocusManager keyInputFocusManager = Toolkit::KeyInputFocusManager::Get();
+    if( keyInputFocusManager )
+    {
+      keyInputFocusManager.UnhandledKeyEventSignal().Connect( this, &PopupExample::OnKeyEvent );
+    }
 
     // Creates a default view with a default tool bar.
     // The view is added to the stage.
@@ -352,7 +357,7 @@ public:
     {
       // Start with a control area image.
       Toolkit::ImageView footer = Toolkit::ImageView::New( DEFAULT_CONTROL_AREA_IMAGE_PATH );
-      footer.SetName( "control-area-image" );
+      footer.SetName( "controlAreaImage" );
       // Set up the container's layout.
       footer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
       footer.SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT );
@@ -407,7 +412,7 @@ public:
   Actor CreateTitle( std::string title )
   {
     Toolkit::TextLabel titleActor = Toolkit::TextLabel::New( title );
-    titleActor.SetName( "title-actor" );
+    titleActor.SetName( "titleActor" );
     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" );
@@ -471,7 +476,7 @@ public:
     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" );
+      TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
       if( typeInfo )
       {
         BaseHandle baseHandle = typeInfo.CreateInstance();
@@ -707,11 +712,6 @@ private:
   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
@@ -726,9 +726,9 @@ void RunTest( Application& application )
 }
 
 // Entry point for Linux & SLP applications
-int main( int argc, char **argv )
+int DALI_EXPORT_API main( int argc, char **argv )
 {
-  Application application = Application::New( &argc, &argv, DALI_DEMO_THEME_PATH );
+  Application application = Application::New( &argc, &argv, DEMO_THEME_PATH );
 
   RunTest( application );