X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=shared%2Fview.h;h=36f42bdd765c60c1a05231af7598168172ae8c10;hb=1b19fd140ff139b5854a1a62447faf31b175d8f6;hp=1ef05ce882d9773cea043ae02623d42c7b2a9d22;hpb=694dced621016315f10a5bdbd3f4552f5e29e380;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/shared/view.h b/shared/view.h index 1ef05ce..36f42bd 100644 --- a/shared/view.h +++ b/shared/view.h @@ -21,21 +21,20 @@ #include #include - namespace DemoHelper { - /** * Provide a style for the view and its tool bar. */ struct ViewStyle { - ViewStyle( float toolBarButtonPercentage, float toolBarTitlePercentage, float toolBarHeight, float toolBarPadding ) - : mToolBarButtonPercentage( toolBarButtonPercentage ), - mToolBarTitlePercentage( toolBarTitlePercentage ), - mToolBarHeight( toolBarHeight ), - mToolBarPadding( toolBarPadding ) - {} + ViewStyle(float toolBarButtonPercentage, float toolBarTitlePercentage, float toolBarHeight, float toolBarPadding) + : mToolBarButtonPercentage(toolBarButtonPercentage), + mToolBarTitlePercentage(toolBarTitlePercentage), + mToolBarHeight(toolBarHeight), + mToolBarPadding(toolBarPadding) + { + } float mToolBarButtonPercentage; ///< The tool bar button width is a percentage of the tool bar width. float mToolBarTitlePercentage; ///< The tool bar title width is a percentage of the tool bar width. @@ -43,122 +42,122 @@ struct ViewStyle float mToolBarPadding; ///< The tool bar padding (in pixels).. }; -const ViewStyle DEFAULT_VIEW_STYLE( 0.1f, 0.7f, 80.f, 4.f ); +const ViewStyle DEFAULT_VIEW_STYLE(0.1f, 0.7f, 80.f, 4.f); -const char* DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNue"); -const float DEFAULT_TEXT_STYLE_POINT_SIZE( 8.0f ); +const char* DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNue"); +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); -Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, - const std::string& toolbarImagePath, - const std::string& title, - const ViewStyle& style ) +Dali::Layer CreateToolbar(Dali::Toolkit::ToolBar& toolBar, + const std::string& toolbarImagePath, + const std::string& title, + const ViewStyle& style) { Dali::Layer toolBarLayer = Dali::Layer::New(); - toolBarLayer.SetProperty( Dali::Actor::Property::NAME, "TOOLBAR_LAYER" ); - toolBarLayer.SetProperty( Dali::Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::TOP_CENTER ); - toolBarLayer.SetProperty( Dali::Actor::Property::PARENT_ORIGIN, Dali::ParentOrigin::TOP_CENTER ); - toolBarLayer.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::WIDTH ); - toolBarLayer.SetProperty( Dali::Actor::Property::SIZE, Dali::Vector2( 0.0f, style.mToolBarHeight ) ); + toolBarLayer.SetProperty(Dali::Actor::Property::NAME, "TOOLBAR_LAYER"); + toolBarLayer.SetProperty(Dali::Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::TOP_CENTER); + toolBarLayer.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, Dali::ParentOrigin::TOP_CENTER); + toolBarLayer.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::WIDTH); + toolBarLayer.SetProperty(Dali::Actor::Property::SIZE, Dali::Vector2(0.0f, style.mToolBarHeight)); // Raise tool bar layer to the top. toolBarLayer.RaiseToTop(); // Tool bar toolBar = Dali::Toolkit::ToolBar::New(); - toolBar.SetProperty( Dali::Actor::Property::NAME, "TOOLBAR" ); + toolBar.SetProperty(Dali::Actor::Property::NAME, "TOOLBAR"); Dali::Property::Map background; background["url"] = toolbarImagePath; - toolBar.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, background ); - toolBar.SetProperty( Dali::Actor::Property::PARENT_ORIGIN, Dali::ParentOrigin::TOP_CENTER ); - toolBar.SetProperty( Dali::Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::TOP_CENTER ); - toolBar.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); + toolBar.SetProperty(Dali::Toolkit::Control::Property::BACKGROUND, background); + toolBar.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, Dali::ParentOrigin::TOP_CENTER); + toolBar.SetProperty(Dali::Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::TOP_CENTER); + toolBar.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS); // Add the tool bar to the tool bar layer. - toolBarLayer.Add( toolBar ); + toolBarLayer.Add(toolBar); // Tool bar text. - if( !title.empty() ) + if(!title.empty()) { Dali::Toolkit::TextLabel label = Dali::Toolkit::TextLabel::New(); - label.SetProperty( Dali::Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::TOP_LEFT ); - label.SetStyleName( "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 ); + label.SetProperty(Dali::Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::TOP_LEFT); + label.SetStyleName("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 ) ); + const float padding(style.mToolBarPadding); + toolBar.AddControl(label, style.mToolBarTitlePercentage, Dali::Toolkit::Alignment::HORIZONTAL_CENTER, Dali::Toolkit::Alignment::Padding(padding, padding, padding, padding)); } return toolBarLayer; } -Dali::Layer CreateView( Dali::Application& application, - Dali::Toolkit::Control& view, - Dali::Toolkit::ToolBar& toolBar, - const std::string& backgroundImagePath, - const std::string& toolbarImagePath, - const std::string& title, - const ViewStyle& style = DEFAULT_VIEW_STYLE ) +Dali::Layer CreateView(Dali::Application& application, + Dali::Toolkit::Control& view, + Dali::Toolkit::ToolBar& toolBar, + const std::string& backgroundImagePath, + const std::string& toolbarImagePath, + const std::string& title, + const ViewStyle& style = DEFAULT_VIEW_STYLE) { Dali::Window window = application.GetWindow(); // Create default View. view = Dali::Toolkit::Control::New(); - view.SetProperty( Dali::Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::CENTER ); - view.SetProperty( Dali::Actor::Property::PARENT_ORIGIN, Dali::ParentOrigin::CENTER ); - view.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); + view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::CENTER); + view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, Dali::ParentOrigin::CENTER); + view.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS); // Add the view to the window before setting the background. - window.Add( view ); + window.Add(view); // Set background image, loading it at screen resolution: - if ( !backgroundImagePath.empty() ) + if(!backgroundImagePath.empty()) { Dali::Property::Map map; - map[Dali::Toolkit::Visual::Property::TYPE] = Dali::Toolkit::Visual::IMAGE; - map[Dali::Toolkit::ImageVisual::Property::URL] = backgroundImagePath; - map[Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH] = window.GetSize().GetWidth(); - map[Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = window.GetSize().GetHeight(); - map[Dali::Toolkit::ImageVisual::Property::FITTING_MODE] = Dali::FittingMode::SCALE_TO_FILL; - map[Dali::Toolkit::ImageVisual::Property::SAMPLING_MODE] = Dali::SamplingMode::BOX_THEN_LINEAR; + map[Dali::Toolkit::Visual::Property::TYPE] = Dali::Toolkit::Visual::IMAGE; + map[Dali::Toolkit::ImageVisual::Property::URL] = backgroundImagePath; + map[Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH] = window.GetSize().GetWidth(); + map[Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = window.GetSize().GetHeight(); + map[Dali::Toolkit::ImageVisual::Property::FITTING_MODE] = Dali::FittingMode::SCALE_TO_FILL; + map[Dali::Toolkit::ImageVisual::Property::SAMPLING_MODE] = Dali::SamplingMode::BOX_THEN_LINEAR; map[Dali::Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = true; - view.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map ); + view.SetProperty(Dali::Toolkit::Control::Property::BACKGROUND, map); } // Create default ToolBar - Dali::Layer toolBarLayer = CreateToolbar( toolBar, toolbarImagePath, title, style ); + Dali::Layer toolBarLayer = CreateToolbar(toolBar, toolbarImagePath, title, style); // Add tool bar layer to the view. - view.Add( toolBarLayer ); + view.Add(toolBarLayer); // Create a content layer. Dali::Layer contentLayer = Dali::Layer::New(); - contentLayer.SetProperty( Dali::Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::CENTER ); - contentLayer.SetProperty( Dali::Actor::Property::PARENT_ORIGIN, Dali::ParentOrigin::CENTER ); - contentLayer.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); - view.Add( contentLayer ); - contentLayer.LowerBelow( toolBarLayer ); + contentLayer.SetProperty(Dali::Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::CENTER); + contentLayer.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, Dali::ParentOrigin::CENTER); + 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 CreateToolBarLabel(const std::string& text) { - Dali::Toolkit::TextLabel label = Dali::Toolkit::TextLabel::New( text ); - label.SetStyleName( "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 ); + Dali::Toolkit::TextLabel label = Dali::Toolkit::TextLabel::New(text); + label.SetStyleName("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 +} // namespace DemoHelper #endif // DALI_DEMO_HELPER_VIEW_H