Files
UnrealEngineUWP/Engine/Source/Editor/ContentBrowser/Private/PathContextMenu.h
Andrew Brown 1b2040bf7b Folder Rename can now be done in the Content Browser Path View
#ttp 342267 - Editor Usability: Select a folder in Content Browser and pressing F2 to rename it, triggers a rename of an actor or asset instead!

#branch UE4

SContentBrowser
Added functions for Can/Execute Rename/Delete which forward to the active context menu
Moved Rename/Delete bind commands to the content browser, so it can forward the request to the correct context menu
(this was necessary as it wasn't possible to bind to both context menus without the code complaining about it already being bound)
Modified GetFolderContextMenu to take an extra param to indicate whether it was the path view or asset view which called it - it then uses this to clear the asset view selection when the path view context menu is requested - we can then use the selection information to determine which context menu was opened later on when processing rename/delete (ideally it should clear when the path view recieves focus, but that's harder to determine).

FAssetContextMenu
Made Can/Execute Rename/Delete public - so they can be called by the Content Browser
Removed BindCommands as it's no longer needed
Removed condition for adding Rename to the menu, as it now always is and is greyed out if not possible.

FPathContextMenu
Added delegate for when rename folder is requested - the same as FAssetContextMenu
Added handling for whether folder renaming is possible, and executing.
Removed condition for adding Rename to the menu, as it now always is and is greyed out if not possible.
Fixed issue with Delete not mapping to keyboard shortcut

SPathView
Added function to rename folder (similar to SAssetView)
Fixed issue with VerifyFolderNameChanged not generating the correct path when checking to see if a folder exists (it was previous just checking to old path - which would always return true).
Modified FolderNameChanged to take 'OldPath' as a param (inline with the delegate change). This function is called when a folder is created or renamed... if it's the latter it has to handle moving the contents of the folder to the new location, which it could only do if it knew where the previous location was (again, similar to SAssetView)

SAssetTreeItem
Added extra param to FOnNameChanged (OldPath) - so we can move assets when a folder is renamed

FTreeItem
Renamed variable bNewFolder to bNamingFolder - as it's true whenever the folder is being named, not just when it's new

reviewed by Thomas.Sarkanen

[CL 2239648 by Andrew Brown in Main branch]
2014-08-01 05:51:26 -04:00

127 lines
4.2 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "NewAssetContextMenu.h"
class FPathContextMenu : public TSharedFromThis<FPathContextMenu>
{
public:
/** Constructor */
FPathContextMenu(const TWeakPtr<SWidget>& InParentContent);
/** Sets the handler for when new assets are requested */
void SetOnNewAssetRequested(const FNewAssetContextMenu::FOnNewAssetRequested& InOnNewAssetRequested);
/** Delegate for when the context menu requests a rename of a folder */
DECLARE_DELEGATE_OneParam(FOnRenameFolderRequested, const FString& /*FolderToRename*/);
void SetOnRenameFolderRequested(const FOnRenameFolderRequested& InOnRenameFolderRequested);
/** Makes the asset tree context menu extender */
TSharedRef<FExtender> MakePathViewContextMenuExtender(const TArray<FString>& InSelectedPaths);
/** Makes the asset tree context menu widget */
void MakePathViewContextMenu(FMenuBuilder& MenuBuilder);
/** Makes the new asset submenu */
void MakeNewAssetSubMenu(FMenuBuilder& MenuBuilder);
/** Makes the set color submenu */
void MakeSetColorSubMenu(FMenuBuilder& MenuBuilder);
/** Handler for when "Migrate Folder" is selected */
void ExecuteMigrateFolder();
/** Handler for when "Explore" is selected */
void ExecuteExplore();
/** Handler to check to see if a rename command is allowed */
bool CanExecuteRename() const;
/** Handler for Rename */
void ExecuteRename();
/** Handler to check to see if a delete command is allowed */
bool CanExecuteDelete() const;
/** Handler for Delete */
void ExecuteDelete();
/** Handler for when reset color is selected */
void ExecuteResetColor();
/** Handler for when new or set color is selected */
void ExecutePickColor();
/** Handler for when "Save" is selected */
void ExecuteSaveFolder();
/** Handler for when "ReferenceViewer" is selected */
void ExecuteReferenceViewer();
/** Handler for when "Fix up Redirectors in Folder" is selected */
void ExecuteFixUpRedirectorsInFolder();
/** Handler for when "Delete" is selected and the delete was confirmed */
FReply ExecuteDeleteFolderConfirmed();
/** Handler for when "Checkout from source control" is selected */
void ExecuteSCCCheckOut();
/** Handler for when "Open for Add to source control" is selected */
void ExecuteSCCOpenForAdd();
/** Handler for when "Checkin to source control" is selected */
void ExecuteSCCCheckIn();
/** Handler for when "Sync from source control" is selected */
void ExecuteSCCSync() const;
/** Handler for when "Connect to source control" is selected */
void ExecuteSCCConnect() const;
/** Handler to check to see if "Checkout from source control" can be executed */
bool CanExecuteSCCCheckOut() const;
/** Handler to check to see if "Open for Add to source control" can be executed */
bool CanExecuteSCCOpenForAdd() const;
/** Handler to check to see if "Checkin to source control" can be executed */
bool CanExecuteSCCCheckIn() const;
/** Handler to check to see if "Connect to source control" can be executed */
bool CanExecuteSCCConnect() const;
private:
/** Initializes some variable used to in "CanExecute" checks that won't change at runtime or are too expensive to check every frame. */
void CacheCanExecuteVars();
/** Returns a list of names of packages in all selected paths in the sources view */
void GetPackageNamesInSelectedPaths(TArray<FString>& OutPackageNames) const;
/** Gets the first selected path, if it exists */
FString GetFirstSelectedPath() const;
/** Checks to see if any of the selected paths use custom colors */
bool SelectedHasCustomColors() const;
/** Callback when the color picker dialog has been closed */
void NewColorComplete(const TSharedRef<SWindow>& Window);
/** Callback when the color is picked from the set color submenu */
FReply OnColorClicked( const FLinearColor InColor );
/** Resets the colors of the selected paths */
void ResetColors();
private:
TArray<FString> SelectedPaths;
TWeakPtr<SWidget> ParentContent;
FNewAssetContextMenu::FOnNewAssetRequested OnNewAssetRequested;
FOnRenameFolderRequested OnRenameFolderRequested;
/** Cached SCC CanExecute vars */
bool bCanExecuteSCCCheckOut;
bool bCanExecuteSCCOpenForAdd;
bool bCanExecuteSCCCheckIn;
};