/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
// EXTERNAL INCLUDES
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
#include <dali-toolkit/devel-api/controls/popup/popup.h>
#include <iostream>
-#include <dali/public-api/events/touch-point.h>
// INTERNAL INCLUDES
#include "shared/multi-language-strings.h"
namespace
{
- const char* const FOLDER_ICON_IMAGE = DALI_IMAGE_DIR "folder_appicon_empty_bg.png";
+ const char* const FOLDER_ICON_IMAGE = DEMO_IMAGE_DIR "folder_appicon_empty_bg.png";
+ const char* const FOLDER_OPEN_ICON_IMAGE = DEMO_IMAGE_DIR "folder_appicon_empty_open_bg.png";
const float BORDER_WIDTH = 4.0f;
- const Vector3 POPUP_SIZE_FACTOR_TO_PARENT = Vector3( 0.0, 0.25, 0.0 );
-
} // unnamed namespace
/**
stage.SetBackgroundColor( Vector4( 0.04f, 0.345f, 0.392f, 1.0f ) );
stage.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent);
+ // Hide the indicator bar
+ application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
+
mButton = CreateFolderButton();
mButton.ClickedSignal().Connect( this, &TextFieldExample::OnButtonClicked );
stage.Add( mButton );
PushButton CreateFolderButton()
{
PushButton button = PushButton::New();
- ResourceImage image = ResourceImage::New( FOLDER_ICON_IMAGE );
- ImageActor folderButton = ImageActor::New( image );
- folderButton.SetColor( Color::WHITE );
- button.SetButtonImage( folderButton );
+ button.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, FOLDER_ICON_IMAGE );
+ button.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, FOLDER_OPEN_ICON_IMAGE );
button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
- button.SetSize( image.GetWidth(), image.GetHeight() );
-
return button;
}
Stage stage = Stage::GetCurrent();
Vector2 stageSize = stage.GetSize();
+ // Remove previously hidden pop-up
+ UnparentAndReset(mPopup);
+
// Launch a pop-up containing TextField
mField = CreateTextField( stageSize, mButtonLabel );
- mPopup = CreatePopup( stageSize.width * 0.8f );
+ mPopup = CreatePopup();
mPopup.Add( mField );
mPopup.OutsideTouchedSignal().Connect( this, &TextFieldExample::OnPopupOutsideTouched );
- mPopup.Show();
+ stage.Add( mPopup );
+ mPopup.SetDisplayState( Popup::SHOWN );
return true;
}
TextField CreateTextField( const Vector2& stageSize, const std::string& text )
{
TextField field = TextField::New();
+ field.SetName("textField");
field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
field.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
return field;
}
- Popup CreatePopup( float width )
+ Popup CreatePopup()
{
Popup popup = Popup::New();
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 );
+ popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::WIDTH );
+ popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
+ popup.TouchSignal().Connect( this, &TextFieldExample::OnPopupTouched );
return popup;
}
{
Property::Value text = mField.GetProperty( TextField::Property::TEXT );
mButtonLabel = text.Get< std::string >();
- mButton.SetLabel( mButtonLabel );
+ mButton.SetProperty( Toolkit::Button::Property::LABEL, mButtonLabel );
}
// Hide & discard the pop-up
if( mPopup )
{
- mPopup.Hide();
+ mPopup.SetDisplayState( Popup::HIDDEN );
}
mField.Reset();
- mPopup.Reset();
}
- bool OnPopupTouched( Actor actor, const TouchEvent& event )
+ bool OnPopupTouched( Actor actor, const TouchData& event )
{
// End edit mode for TextField if parent Popup touched.
if(event.GetPointCount() > 0)
{
- const TouchPoint& point = event.GetPoint(0);
- switch(point.state)
+ switch( event.GetState( 0 ) )
{
- case TouchPoint::Down:
+ case PointState::DOWN:
{
// Update the folder text and lose focus for Key events
if( mButton && mField )
{
Property::Value text = mField.GetProperty( TextField::Property::TEXT );
mButtonLabel = text.Get< std::string >();
- mButton.SetLabel( mButtonLabel );
+ mButton.SetProperty( Toolkit::Button::Property::LABEL, mButtonLabel );
mField.ClearKeyInputFocus();
}
break;
}
/** Entry point for Linux & Tizen 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 );
+ // DALI_DEMO_THEME_PATH not passed to Application so TextField example uses default Toolkit style sheet.
+ Application application = Application::New( &argc, &argv );
RunTest( application );