Files
UnrealEngineUWP/Engine/Source/Editor/UnrealEd/Public/SViewportToolBarComboMenu.h
Michael Noland 1263a3db47 Slate: Added the ability to specify a minimum desired width for SViewportToolBarComboMenu
[CL 2554351 by Michael Noland in Main branch]
2015-05-17 19:26:24 -04:00

80 lines
2.2 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "SViewportToolBar.h"
/**
* Custom widget to display a toggle/drop down menu.
* Displayed as shown:
* +--------+-------------+
* | Toggle | Menu button |
* +--------+-------------+
*/
class UNREALED_API SViewportToolBarComboMenu : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SViewportToolBarComboMenu) : _BlockLocation(EMultiBlockLocation::Start), _MinDesiredButtonWidth(-1.0f) {}
/** We need to know about the toolbar we are in */
SLATE_ARGUMENT( TSharedPtr<class SViewportToolBar>, ParentToolBar );
/** Content for the drop down menu */
SLATE_EVENT( FOnGetContent, OnGetMenuContent )
/** Called upon state change with the value of the next state */
SLATE_EVENT( FOnCheckStateChanged, OnCheckStateChanged )
/** Sets the current checked state of the checkbox */
SLATE_ATTRIBUTE( ECheckBoxState, IsChecked )
/** Icon shown on the toggle button */
SLATE_ATTRIBUTE( FSlateIcon, Icon )
/** Label shown on the menu button */
SLATE_ATTRIBUTE( FText, Label )
/** Overall style */
SLATE_ATTRIBUTE( FName, Style )
/** ToolTip shown on the menu button */
SLATE_ATTRIBUTE( FText, MenuButtonToolTip )
/** ToolTip shown on the toggle button */
SLATE_ATTRIBUTE( FText, ToggleButtonToolTip )
/** The button location */
SLATE_ARGUMENT( EMultiBlockLocation::Type, BlockLocation )
/** The minimum desired width of the menu button contents */
SLATE_ARGUMENT( float, MinDesiredButtonWidth )
SLATE_END_ARGS( )
/**
* Construct this widget
*
* @param InArgs The declaration data for this widget
*/
void Construct( const FArguments& InArgs );
private:
/**
* Called when the menu button is clicked. Will toggle the visibility of the menu content
*/
FReply OnMenuClicked();
/**
* Called when the mouse enters a menu button. If there was a menu previously opened
* we open this menu automatically
*/
void OnMouseEnter( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent );
private:
/** Our menus anchor */
TSharedPtr<SMenuAnchor> MenuAnchor;
/** Parent tool bar for querying other open menus */
TWeakPtr<class SViewportToolBar> ParentToolBar;
};