89 lines
2.5 KiB
C++
89 lines
2.5 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Misc/Attribute.h"
|
|
#include "Layout/Visibility.h"
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
#include "Input/Reply.h"
|
|
#include "Widgets/SCompoundWidget.h"
|
|
#include "SViewportToolBar.h"
|
|
#include "Framework/SlateDelegates.h"
|
|
#include "Styling/SlateTypes.h"
|
|
#include "EditorStyleSet.h"
|
|
#include "Styling/SlateWidgetStyleAsset.h"
|
|
|
|
class SMenuAnchor;
|
|
struct FSlateBrush;
|
|
|
|
namespace EMenuItemType
|
|
{
|
|
enum Type
|
|
{
|
|
Default,
|
|
Header,
|
|
Separator,
|
|
};
|
|
} // namespace EMenuItemType
|
|
|
|
/**
|
|
* Widget that opens a menu when clicked
|
|
*/
|
|
class UNREALED_API SEditorViewportToolbarMenu: public SCompoundWidget
|
|
{
|
|
public:
|
|
SLATE_BEGIN_ARGS(SEditorViewportToolbarMenu)
|
|
: _MenuStyle(&FEditorStyle::Get().GetWidgetStyle<FButtonStyle>("EditorViewportToolBar.MenuButton"))
|
|
{}
|
|
/** We need to know about the toolbar we are in */
|
|
SLATE_ARGUMENT(TSharedPtr<class SViewportToolBar>, ParentToolBar);
|
|
/** Style to use */
|
|
SLATE_STYLE_ARGUMENT(FButtonStyle, MenuStyle)
|
|
/** The label to show in the menu */
|
|
SLATE_ATTRIBUTE(FText, Label)
|
|
/** Optional icon to display next to the label */
|
|
SLATE_ATTRIBUTE(const FSlateBrush*, LabelIcon)
|
|
/** The image to show in the menu. If both the label and image are valid, the button image is used. Note that if this image is used, the label icon will not be displayed. */
|
|
SLATE_ARGUMENT(FName, Image)
|
|
/** Content to show in the menu */
|
|
SLATE_EVENT(FOnGetContent, OnGetMenuContent)
|
|
SLATE_END_ARGS()
|
|
|
|
/**
|
|
* Constructs the menu
|
|
*/
|
|
void Construct(const FArguments& Declaration);
|
|
|
|
/**
|
|
* Returns parent tool bar
|
|
*/
|
|
TWeakPtr<class SViewportToolBar> GetParentToolBar() const;
|
|
|
|
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);
|
|
|
|
EVisibility GetLabelIconVisibility() const;
|
|
|
|
protected:
|
|
/** Parent tool bar for querying other open menus */
|
|
TWeakPtr<class SViewportToolBar> ParentToolBar;
|
|
|
|
/** Name of tool menu */
|
|
FName MenuName;
|
|
|
|
private:
|
|
/** Our menus anchor */
|
|
TSharedPtr<SMenuAnchor> MenuAnchor;
|
|
TAttribute<const FSlateBrush*> LabelIconBrush;
|
|
};
|