- void ShowMenu()
- {
- Stage stage = Stage::GetCurrent();
- const float popupWidth = stage.GetSize().x * 0.75f;
-
- mMenu = Toolkit::Popup::New();
- mMenu.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
- mMenu.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
- mMenu.SetSize( popupWidth, MENU_OPTION_HEIGHT * 2 );
- mMenu.OutsideTouchedSignal().Connect( this, &ItemViewExample::HideMenu );
-
- TableView tableView = TableView::New( 0, 0 );
- tableView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- mMenu.Add( tableView );
-
- Slider slider = Slider::New();
- slider.SetProperty( Slider::Property::LOWER_BOUND, 0.0f );
- slider.SetProperty( Slider::Property::UPPER_BOUND, 3.0f );
- slider.SetProperty( Slider::Property::VALUE, mDurationSeconds );
- slider.SetProperty( Slider::Property::VALUE_PRECISION, 2 );
- slider.SetProperty( Slider::Property::SHOW_POPUP, true );
- slider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- slider.ValueChangedSignal().Connect( this, &ItemViewExample::SliderValueChange );
- tableView.AddChild( slider, TableView::CellPosition( 0, 0 ) );
-
- TextLabel text = TextLabel::New( "Duration" );
- text.SetAnchorPoint( ParentOrigin::TOP_LEFT );
- text.SetParentOrigin( ParentOrigin::TOP_LEFT );
- text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
- text.SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT );
- text.SetSize( Vector2( 0.0f, LABEL_TEXT_SIZE_Y ) );
- slider.Add( text );
-
- Actor textContainer = Actor::New();
- textContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- mAlphaFunctionText = TextLabel::New( ALPHA_FUNCTIONS_TEXT[mAlphaFuncIndex] );
- mAlphaFunctionText.SetAnchorPoint( ParentOrigin::CENTER );
- mAlphaFunctionText.SetParentOrigin( ParentOrigin::CENTER );
- textContainer.Add( mAlphaFunctionText );
- tableView.AddChild( textContainer, TableView::CellPosition( 1, 0 ) );
-
- mTapDetector = TapGestureDetector::New();
- mTapDetector.Attach(mAlphaFunctionText);
- mTapDetector.DetectedSignal().Connect( this, &ItemViewExample::ChangeAlphaFunctionOnTap );
-
- text = TextLabel::New( "Alpha Function" );
- text.SetAnchorPoint( ParentOrigin::TOP_LEFT );
- text.SetParentOrigin( ParentOrigin::TOP_LEFT );
- text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
- text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y );
- textContainer.Add( text );
-
- mMenu.Show();
- mMenuShown = true;
- }
-
- bool SliderValueChange( Toolkit::Slider slider, float value )
- {
- mDurationSeconds = value;
-
- return true;
- }
-
- void ChangeAlphaFunctionOnTap( Actor actor, const TapGesture& tap )
- {
- if( NUM_ALPHA_FUNCTIONS <= ++mAlphaFuncIndex )
- {
- mAlphaFuncIndex = 0;
- }
-
- if( mAlphaFunctionText )
- {
- mAlphaFunctionText.SetProperty( TextLabel::Property::TEXT, std::string(ALPHA_FUNCTIONS_TEXT[mAlphaFuncIndex]) );
- }
-
- if( mItemView )
- {
- mItemView.GetActiveLayout()->SetAlphaFunction( ALPHA_FUNCTIONS[mAlphaFuncIndex] );
- }
- }
-
- void HideMenu()
- {
- mTapDetector.Reset();
-
- if( mMenu )
- {
- mMenu.Hide();
- mMenu.Reset();
- }
-
- mMenuShown = false;
- }
-