X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=shared%2Fview.h;h=6af332439a958c75e1315f444476ca14f9097f13;hb=d2223117baea75e170556014107fbc6455c02cbc;hp=123fdefde85a3c2a30e6d4fd4cd0b83ffcdf288f;hpb=140cc98f0888554b3dc1fa5c36a8a5680bdf66bd;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/shared/view.h b/shared/view.h index 123fdef..6af3324 100644 --- a/shared/view.h +++ b/shared/view.h @@ -19,6 +19,8 @@ */ #include +#include + namespace DemoHelper { @@ -45,7 +47,7 @@ const ViewStyle DEFAULT_VIEW_STYLE( 0.1f, 0.7f, 80.f, 4.f ); const char* DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNue"); const char* DEFAULT_TEXT_STYLE_FONT_STYLE("Regular"); -const Dali::Vector4 DEFAULT_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f); +const float DEFAULT_TEXT_STYLE_POINT_SIZE( 8.0f ); const Dali::Toolkit::Alignment::Padding DEFAULT_PLAY_PADDING(12.0f, 12.0f, 12.0f, 12.0f); const Dali::Toolkit::Alignment::Padding DEFAULT_MODE_SWITCH_PADDING(8.0f, 8.0f, 8.0f, 8.0f); @@ -62,10 +64,13 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, const std::string& title, const ViewStyle& style ) { + Dali::Stage stage = Dali::Stage::GetCurrent(); + Dali::Layer toolBarLayer = Dali::Layer::New(); + toolBarLayer.SetName( "TOOLBAR_LAYER" ); toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); - toolBarLayer.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::SourceWidthFixedHeight( style.mToolBarHeight ) ) ); + toolBarLayer.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::WIDTH ); toolBarLayer.SetSize( 0.0f, style.mToolBarHeight ); // Raise tool bar layer to the top. @@ -73,14 +78,12 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, // Tool bar Dali::Image image = Dali::ResourceImage::New( toolbarImagePath ); - Dali::ImageActor toolBarBackground = Dali::ImageActor::New( image ); toolBar = Dali::Toolkit::ToolBar::New(); - toolBar.SetBackground( toolBarBackground ); + toolBar.SetName( "TOOLBAR" ); + toolBar.SetBackgroundImage( image ); toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); - toolBar.SetSize( 0.0f, style.mToolBarHeight ); - toolBar.SetSizeMode( Dali::SIZE_EQUAL_TO_PARENT ); - toolBarBackground.SetSortModifier(1.0f); + toolBar.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); // Add the tool bar to the too bar layer. toolBarLayer.Add( toolBar ); @@ -88,14 +91,24 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, // Tool bar text. if( !title.empty() ) { - // TODO + Dali::Toolkit::TextLabel label = Dali::Toolkit::TextLabel::New(); + label.SetAnchorPoint( Dali::AnchorPoint::TOP_LEFT ); + label.SetProperty( Dali::Toolkit::Control::Property::STYLE_NAME, "toolbarlabel" ); + label.SetProperty( Dali::Toolkit::TextLabel::Property::TEXT, title ); + label.SetProperty( Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + label.SetProperty( Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); + label.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT ); + + // Add title to the tool bar. + const float padding( style.mToolBarPadding ); + toolBar.AddControl( label, style.mToolBarTitlePercentage, Dali::Toolkit::Alignment::HorizontalCenter, Dali::Toolkit::Alignment::Padding( padding, padding, padding, padding ) ); } return toolBarLayer; } Dali::Layer CreateView( Dali::Application& application, - Dali::Toolkit::View& view, + Dali::Toolkit::Control& view, Dali::Toolkit::ToolBar& toolBar, const std::string& backgroundImagePath, const std::string& toolbarImagePath, @@ -105,7 +118,10 @@ Dali::Layer CreateView( Dali::Application& application, Dali::Stage stage = Dali::Stage::GetCurrent(); // Create default View. - view = Dali::Toolkit::View::New(); + view = Dali::Toolkit::Control::New(); + view.SetAnchorPoint( Dali::AnchorPoint::CENTER ); + view.SetParentOrigin( Dali::ParentOrigin::CENTER ); + view.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); // Add the view to the stage before setting the background. stage.Add( view ); @@ -113,13 +129,8 @@ Dali::Layer CreateView( Dali::Application& application, // Set background image, loading it at screen resolution: if ( !backgroundImagePath.empty() ) { - Dali::ImageAttributes backgroundAttributes; - backgroundAttributes.SetSize( stage.GetSize() ); - backgroundAttributes.SetFilterMode( Dali::ImageAttributes::BoxThenLinear ); - backgroundAttributes.SetScalingMode( Dali::ImageAttributes::ScaleToFill ); - Dali::Image backgroundImage = Dali::ResourceImage::New( backgroundImagePath, backgroundAttributes ); - Dali::ImageActor backgroundImageActor = Dali::ImageActor::New( backgroundImage ); - view.SetBackground( backgroundImageActor ); + Dali::Image backgroundImage = Dali::ResourceImage::New( backgroundImagePath, Dali::ImageDimensions( stage.GetSize().x, stage.GetSize().y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); + view.SetBackgroundImage( backgroundImage ); } // FIXME @@ -130,21 +141,30 @@ Dali::Layer CreateView( Dali::Application& application, Dali::Layer toolBarLayer = CreateToolbar( toolBar, toolbarImagePath, title, style ); // Add tool bar layer to the view. - view.AddContentLayer( toolBarLayer ); - - + view.Add( toolBarLayer ); // Create a content layer. Dali::Layer contentLayer = Dali::Layer::New(); contentLayer.SetAnchorPoint( Dali::AnchorPoint::CENTER ); contentLayer.SetParentOrigin( Dali::ParentOrigin::CENTER ); - contentLayer.SetSizeMode( Dali::SIZE_EQUAL_TO_PARENT ); - view.AddContentLayer( contentLayer ); + contentLayer.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); + view.Add( contentLayer ); contentLayer.LowerBelow( toolBarLayer ); return contentLayer; } +Dali::Toolkit::TextLabel CreateToolBarLabel( const std::string& text ) +{ + Dali::Toolkit::TextLabel label = Dali::Toolkit::TextLabel::New( text ); + label.SetProperty( Dali::Toolkit::Control::Property::STYLE_NAME, "toolbarlabel" ); + label.SetProperty( Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + label.SetProperty( Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); + label.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT ); + + return label; +} + } // DemoHelper #endif // __DALI_DEMO_HELPER_VIEW_H__