X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fstyling%2Fstyling-application.cpp;h=ff8875075f5dfa7ee681dd39b9334a22dc3b6f23;hb=a832af2813558a32f0a18747f3e6134ff6f6f301;hp=b37279ced89a3090fc4f5ac12f63e277cb4de91b;hpb=0a28d6445ef0ce95e46769a0c4208291ff094603;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/styling/styling-application.cpp b/examples/styling/styling-application.cpp index b37279c..ff88750 100644 --- a/examples/styling/styling-application.cpp +++ b/examples/styling/styling-application.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -24,7 +24,6 @@ // External includes #include -//#include #include #include "image-channel-control.h" #include @@ -92,7 +91,8 @@ Property::Index GetChannelProperty( int index ) StylingApplication::StylingApplication( Application& application ) -: mApplication( application ) +: mApplication( application ), + mCurrentTheme( 0 ) { application.InitSignal().Connect( this, &StylingApplication::Create ); } @@ -135,7 +135,7 @@ void StylingApplication::Create( Application& application ) mTitle = TextLabel::New( "Styling Example" ); mTitle.SetName( "Title" ); - mTitle.SetStyleName("title"); + mTitle.SetStyleName("Title"); mTitle.SetAnchorPoint( AnchorPoint::TOP_CENTER ); mTitle.SetParentOrigin( ParentOrigin::TOP_CENTER ); mTitle.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); @@ -176,7 +176,7 @@ void StylingApplication::Create( Application& application ) for( int i=0; i<3; ++i ) { std::ostringstream thumbnailName; thumbnailName << "thumbnail" << i+1; - ImageView image = ImageView::New( ResourceImage::New( images[i] ) ); + ImageView image = ImageView::New( images[i] ); image.SetName( thumbnailName.str() ); image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); @@ -187,7 +187,7 @@ void StylingApplication::Create( Application& application ) mRadioButtons[i].SetName( radioButtonStyleName.str() ); mRadioButtons[i].SetParentOrigin( ParentOrigin::TOP_LEFT ); mRadioButtons[i].SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mRadioButtons[i].SetSelected( false ); + mRadioButtons[i].SetProperty( Button::Property::SELECTED, false ); mRadioButtons[i].StateChangedSignal().Connect( this, &StylingApplication::OnButtonStateChange ); radioButtonsLayout.AddChild( mRadioButtons[i], TableView::CellPosition( i, 0 ) ); @@ -196,16 +196,43 @@ void StylingApplication::Create( Application& application ) radioButtonsLayout.SetCellAlignment( TableView::CellPosition( i, 1 ), HorizontalAlignment::CENTER, VerticalAlignment::CENTER ); } - mRadioButtons[0].SetSelected( true ); - - mImageChannelControl = ImageChannelControl::New( BIG_IMAGE_1 ); - mImageChannelControl.SetName("ImageChannelControl"); - mImageChannelControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT , Dimension::ALL_DIMENSIONS ); - mImageChannelControl.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); - imageSelectLayout.AddChild( mImageChannelControl, TableView::CellPosition( 0, 1 ) ); + mRadioButtons[0].SetProperty( Button::Property::SELECTED, true ); + mImagePlacement = Actor::New(); + mImagePlacement.SetParentOrigin( ParentOrigin::CENTER ); + mImagePlacement.SetAnchorPoint( AnchorPoint::CENTER ); + mImagePlacement.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + imageSelectLayout.AddChild( mImagePlacement, TableView::CellPosition( 0, 1 ) ); imageSelectLayout.SetCellAlignment( TableView::CellPosition( 0, 1 ), HorizontalAlignment::RIGHT, VerticalAlignment::CENTER ); + mIcc1 = ImageChannelControl::New( BIG_IMAGE_1 ); + mIcc1.SetName("ICC1"); + mIcc1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT , Dimension::ALL_DIMENSIONS ); + mIcc1.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); + mIcc1.SetParentOrigin( ParentOrigin::CENTER ); + mIcc1.SetVisibility( true ); + + mImagePlacement.Add( mIcc1 ); + + mIcc2 = ImageChannelControl::New( BIG_IMAGE_2 ); + mIcc2.SetName("ICC2"); + mIcc2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT , Dimension::ALL_DIMENSIONS ); + mIcc2.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); + mIcc2.SetParentOrigin( ParentOrigin::CENTER ); + mIcc2.SetVisibility( false ); + + mImagePlacement.Add( mIcc2 ); + + mIcc3 = ImageChannelControl::New( BIG_IMAGE_3 ); + mIcc3.SetName("ICC3"); + mIcc3.SetResizePolicy( ResizePolicy::FILL_TO_PARENT , Dimension::ALL_DIMENSIONS ); + mIcc3.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); + mIcc3.SetParentOrigin( ParentOrigin::CENTER ); + mIcc3.SetVisibility( false ); + + mImagePlacement.Add( mIcc3 ); + + mImageChannelControl = mIcc1; TableView channelSliderLayout = TableView::New( 3, 3 ); channelSliderLayout.SetName("ChannelSliderLayout"); @@ -237,7 +264,7 @@ void StylingApplication::Create( Application& application ) mCheckButtons[i].SetName( checkBoxStyleName.str() ); mCheckButtons[i].SetParentOrigin( ParentOrigin::CENTER ); mCheckButtons[i].SetAnchorPoint( AnchorPoint::CENTER ); - mCheckButtons[i].SetSelected( true ); + mCheckButtons[i].SetProperty( Button::Property::SELECTED, true ); mCheckButtons[i].StateChangedSignal().Connect( this, &StylingApplication::OnCheckButtonChange ); mCheckButtons[i].RegisterProperty( "channel", i, Property::READ_WRITE ); @@ -246,7 +273,7 @@ void StylingApplication::Create( Application& application ) channelSliderLayout.SetCellAlignment( TableView::CellPosition( i, 0 ), HorizontalAlignment::CENTER, VerticalAlignment::CENTER ); TextLabel label = TextLabel::New( checkboxLabels[i] ); - std::ostringstream labelStyleName; labelStyleName << "colorLabel" << i+1; + std::ostringstream labelStyleName; labelStyleName << "ColorLabel" << i+1; label.SetName( labelStyleName.str() ); label.SetStyleName( labelStyleName.str() ); label.SetParentOrigin( ParentOrigin::CENTER ); @@ -258,7 +285,7 @@ void StylingApplication::Create( Application& application ) channelSliderLayout.SetCellAlignment( TableView::CellPosition( i, 1 ), HorizontalAlignment::CENTER, VerticalAlignment::CENTER ); mChannelSliders[i] = Slider::New(); - std::ostringstream sliderStyleName; sliderStyleName << "colorSlider" << i+1; + std::ostringstream sliderStyleName; sliderStyleName << "ColorSlider" << i+1; mChannelSliders[i].SetName( sliderStyleName.str() ); mChannelSliders[i].SetStyleName( sliderStyleName.str() ); mChannelSliders[i].SetParentOrigin( ParentOrigin::CENTER ); @@ -281,7 +308,7 @@ void StylingApplication::Create( Application& application ) } mResetButton = PushButton::New(); - mResetButton.SetLabelText( "Reset" ); + mResetButton.SetProperty( Toolkit::Button::Property::LABEL, "Reset" ); mResetButton.SetName("ResetButton"); mResetButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); mResetButton.ClickedSignal().Connect( this, &StylingApplication::OnResetClicked ); @@ -302,7 +329,7 @@ void StylingApplication::Create( Application& application ) TextLabel label = TextLabel::New( "Theme: "); label.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); - label.SetStyleName("themelabel"); + label.SetStyleName("ThemeLabel"); label.SetAnchorPoint( AnchorPoint::TOP_CENTER ); label.SetParentOrigin( ParentOrigin::TOP_CENTER ); themeButtonLayout.AddChild( label, TableView::CellPosition( 0, 0 ) ); @@ -321,9 +348,9 @@ void StylingApplication::Create( Application& application ) mThemeButtons[i].ClickedSignal().Connect( this, &StylingApplication::OnThemeButtonClicked ); themeButtonLayout.AddChild( mThemeButtons[i], TableView::CellPosition( 0, 1+i ) ); } - mThemeButtons[0].SetLabelText( "Lite" ); // Lightweight changes on top of Dali - mThemeButtons[1].SetLabelText( "App1" ); // Different application style - mThemeButtons[2].SetLabelText( "App2" ); + mThemeButtons[0].SetProperty( Toolkit::Button::Property::LABEL, "Lite" ); // Lightweight changes on top of Dali + mThemeButtons[1].SetProperty( Toolkit::Button::Property::LABEL, "App1" ); // Different application style + mThemeButtons[2].SetProperty( Toolkit::Button::Property::LABEL, "App2" ); contentLayout.Add( themeButtonLayout ); } @@ -386,7 +413,7 @@ Popup StylingApplication::CreateResetPopup() TextLabel text = TextLabel::New( "This will reset the channel data to full value. Are you sure?" ); text.SetName( "PopupContentText" ); - text.SetStyleName( "popupBody" ); + text.SetStyleName( "PopupBody" ); text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); text.SetProperty( TextLabel::Property::MULTI_LINE, true ); @@ -410,7 +437,7 @@ Popup StylingApplication::CreateResetPopup() PushButton okayButton = PushButton::New(); okayButton.SetName( POPUP_CONTROL_OK_NAME ); okayButton.SetStyleName( POPUP_CONTROL_OK_NAME ); - okayButton.SetLabelText( "Ok!" ); + okayButton.SetProperty( Toolkit::Button::Property::LABEL, "Ok!" ); okayButton.ClickedSignal().Connect( this, &StylingApplication::OnReset ); okayButton.SetParentOrigin( ParentOrigin::CENTER ); okayButton.SetAnchorPoint( AnchorPoint::CENTER ); @@ -420,7 +447,7 @@ Popup StylingApplication::CreateResetPopup() PushButton cancelButton = PushButton::New(); cancelButton.SetName( POPUP_CONTROL_CANCEL_NAME ); cancelButton.SetStyleName( POPUP_CONTROL_CANCEL_NAME ); - cancelButton.SetLabelText( "Cancel" ); + cancelButton.SetProperty( Toolkit::Button::Property::LABEL, "Cancel" ); cancelButton.ClickedSignal().Connect( this, &StylingApplication::OnResetCancelled ); cancelButton.SetParentOrigin( ParentOrigin::CENTER ); cancelButton.SetAnchorPoint( AnchorPoint::CENTER ); @@ -442,7 +469,7 @@ TextLabel StylingApplication::CreateTitle( std::string title ) { TextLabel titleActor = TextLabel::New( title ); titleActor.SetName( "titleActor" ); - titleActor.SetStyleName( "popupTitle" ); + titleActor.SetStyleName( "PopupTitle" ); titleActor.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); titleActor.SetProperty( TextLabel::Property::MULTI_LINE, false ); @@ -451,23 +478,40 @@ TextLabel StylingApplication::CreateTitle( std::string title ) bool StylingApplication::OnButtonStateChange( Button button ) { - // Todo: save / restore slider states per image + // On button press, called twice, once to tell new button it's selected, + // once to tell old button it isn't selected? - if( mImageChannelControl ) +// Todo: save / restore slider states per image + + if( button.GetProperty(Button::Property::SELECTED) ) { - if( mRadioButtons[0].IsSelected() ) + + ImageChannelControl prevIcc = mImageChannelControl; + + if( mRadioButtons[0].GetProperty(Button::Property::SELECTED) ) { - mImageChannelControl.SetImage( BIG_IMAGE_1 ); + mImageChannelControl = mIcc1; } - else if( mRadioButtons[1].IsSelected() ) + else if( mRadioButtons[1].GetProperty(Button::Property::SELECTED) ) { - mImageChannelControl.SetImage( BIG_IMAGE_2 ); + mImageChannelControl = mIcc2; } - else if( mRadioButtons[2].IsSelected() ) + else if( mRadioButtons[2].GetProperty(Button::Property::SELECTED) ) { - mImageChannelControl.SetImage( BIG_IMAGE_3 ); + mImageChannelControl = mIcc3; + } + + if( prevIcc ) + { + prevIcc.SetVisibility( false ); + } + + if( mImageChannelControl ) + { + mImageChannelControl.SetVisibility( true ); } } + return true; } @@ -478,7 +522,7 @@ bool StylingApplication::OnCheckButtonChange( Button button ) { int channel = button.GetProperty( index ); float value = mChannelSliders[channel].GetProperty( Slider::Property::VALUE ); - if( !button.IsSelected() ) + if( !button.GetProperty(Button::Property::SELECTED) ) { // "Turn off" the channel's contribution value = 0.0f; @@ -512,6 +556,7 @@ bool StylingApplication::OnThemeButtonClicked( Button button ) break; } } + StyleManager::Get().ApplyTheme( themePath ); return true; @@ -554,7 +599,7 @@ bool StylingApplication::OnSliderChanged( Slider slider, float value ) if( index != Property::INVALID_INDEX ) { int channel = slider.GetProperty( index ); - if( mCheckButtons[channel].IsSelected() ) + if( mCheckButtons[channel].GetProperty(Button::Property::SELECTED) ) { Property::Index channelIndex = GetChannelProperty( channel ); mImageChannelControl.SetProperty(channelIndex, value/100.0f);