ShowFlag.ModeWidgets

ShowFlag.ModeWidgets

#Overview

name: ShowFlag.ModeWidgets

This variable is created as a Console Variable (cvar).

It is referenced in 16 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.ModeWidgets is to control the visibility of mode-specific widgets and controls in the viewport. It is primarily used in the editor for level editing and manipulation.

This setting variable is relied upon by several Unreal Engine subsystems and modules, including:

  1. The Paper2D editor module
  2. The DisplayClusterConfigurator module
  3. The EditorInteractiveToolsFramework
  4. The Kismet editor
  5. The UnrealEd module
  6. The LevelEditor viewport

The value of this variable is typically set within the engine’s show flags system, which controls the visibility of various elements in the viewport. It can be toggled on or off depending on the current editing context.

The associated variable ModeWidgets interacts directly with ShowFlag.ModeWidgets. They share the same value and are used interchangeably in the code.

Developers must be aware that:

  1. This flag should only be set on viewport clients that are editing the level itself.
  2. Toggling this flag affects the visibility of editing widgets, gizmos, and other mode-specific controls.
  3. It can impact performance, as rendering these widgets requires additional processing.

Best practices when using this variable include:

  1. Only enable it when necessary for editing operations.
  2. Ensure it’s disabled when not actively editing to improve performance.
  3. Be cautious when modifying its state, as it can affect the user’s ability to interact with the scene.

Regarding the associated variable ModeWidgets: The purpose of ModeWidgets is the same as ShowFlag.ModeWidgets. It is used interchangeably in the code to control the visibility of mode-specific widgets in the viewport. The same considerations, best practices, and awareness points apply to this variable as well. Developers should treat ModeWidgets and ShowFlag.ModeWidgets as equivalent when working with viewport widget visibility.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:255

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(0, EditingLevelInstance, SFG_Transient, NSLOCTEXT("UnrealEd", "EditingLevelInstanceSF", "Editing LevelInstance"))
/** Draws mode specific widgets and controls in the viewports (should only be set on viewport clients that are editing the level itself) */
SHOWFLAG_FIXED_IN_SHIPPING(0, ModeWidgets, SFG_Advanced, NSLOCTEXT("UnrealEd", "ModeWidgetsSF", "Mode Widgets"))
/**  */
SHOWFLAG_FIXED_IN_SHIPPING(0, Bounds,  SFG_Advanced, NSLOCTEXT("UnrealEd", "BoundsSF", "Bounds"))
/** Draws each hit proxy in the scene with a different color, for now only available in the editor */
SHOWFLAG_FIXED_IN_SHIPPING(0, HitProxies, SFG_Developer, NSLOCTEXT("UnrealEd", "HitProxiesSF", "Hit Proxies"))
/** Draw lines to lights affecting this mesh if its selected. */
SHOWFLAG_FIXED_IN_SHIPPING(0, LightInfluences, SFG_Advanced, NSLOCTEXT("UnrealEd", "LightInfluencesSF", "Light Influences"))

#Associated Variable and Callsites

This variable is associated with another variable named ModeWidgets. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Plugins/2D/Paper2D/Source/Paper2DEditor/Private/TileMapEditing/EdModeTileMap.cpp:268

Scope (from outer to inner):

file
function     bool FEdModeTileMap::MouseEnter

Source code excerpt:

bool FEdModeTileMap::MouseEnter(FEditorViewportClient* ViewportClient, FViewport* Viewport, int32 x, int32 y)
{
	if (ViewportClient->EngineShowFlags.ModeWidgets)
	{
		const FViewportCursorLocation Ray = CalculateViewRay(ViewportClient, Viewport);
		UpdatePreviewCursor(Ray);
	}

	RefreshBrushSize();

#Loc: <Workspace>/Engine/Plugins/2D/Paper2D/Source/Paper2DEditor/Private/TileMapEditing/EdModeTileMap.cpp:291

Scope (from outer to inner):

file
function     bool FEdModeTileMap::MouseMove

Source code excerpt:

bool FEdModeTileMap::MouseMove(FEditorViewportClient* InViewportClient, FViewport* InViewport, int32 x, int32 y)
{
	if (InViewportClient->EngineShowFlags.ModeWidgets)
	{
		const FViewportCursorLocation Ray = CalculateViewRay(InViewportClient, InViewport);
		UpdatePreviewCursor(Ray);
	}

	// Overridden to prevent the default behavior

#Loc: <Workspace>/Engine/Plugins/2D/Paper2D/Source/Paper2DEditor/Private/TileMapEditing/EdModeTileMap.cpp:303

Scope (from outer to inner):

file
function     bool FEdModeTileMap::CapturedMouseMove

Source code excerpt:

bool FEdModeTileMap::CapturedMouseMove(FEditorViewportClient* InViewportClient, FViewport* InViewport, int32 InMouseX, int32 InMouseY)
{
	if (InViewportClient->EngineShowFlags.ModeWidgets)
	{
		const FViewportCursorLocation Ray = CalculateViewRay(InViewportClient, InViewport);
		
		UpdatePreviewCursor(Ray);

		if (bIsPainting)

#Loc: <Workspace>/Engine/Plugins/2D/Paper2D/Source/Paper2DEditor/Private/TileMapEditing/EdModeTileMap.cpp:344

Scope (from outer to inner):

file
function     bool FEdModeTileMap::InputKey

Source code excerpt:

	RefreshBrushSize();

	if (InViewportClient->EngineShowFlags.ModeWidgets)
	{
		// Does the user want to paint right now?
		bWasPainting = bIsPainting;
		const bool bUserWantsPaint = bIsLeftButtonDown;
		bool bAnyPaintAbleActorsUnderCursor = false;
		bIsPainting = bUserWantsPaint;

#Loc: <Workspace>/Engine/Plugins/2D/Paper2D/Source/Paper2DEditor/Private/TileMapEditing/EdModeTileMap.cpp:396

Scope (from outer to inner):

file
function     void FEdModeTileMap::Render

Source code excerpt:

	// If this viewport does not support Mode widgets we will not draw it here.
	FEditorViewportClient* ViewportClient = (FEditorViewportClient*)Viewport->GetClient();
	if ((ViewportClient != nullptr) && !ViewportClient->EngineShowFlags.ModeWidgets)
	{
		return;
	}

	// Determine if the active tool is in a valid state
	const bool bToolIsReadyToDraw = IsToolReadyToBeUsed();

#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayClusterConfigurator/Private/Views/Viewport/DisplayClusterConfiguratorSCSEditorViewportClient.cpp:428

Scope (from outer to inner):

file
function     void FDisplayClusterConfiguratorSCSEditorViewportClient::ProcessClick

Source code excerpt:

		if (HitProxy->IsA(HWidgetAxis::StaticGetType()))
		{
			const bool bOldModeWidgets1 = EngineShowFlags.ModeWidgets;
			const bool bOldModeWidgets2 = View.Family->EngineShowFlags.ModeWidgets;

			EngineShowFlags.SetModeWidgets(false);
			FSceneViewFamily* SceneViewFamily = const_cast<FSceneViewFamily*>(View.Family);
			SceneViewFamily->EngineShowFlags.SetModeWidgets(false);
			bool bWasWidgetDragging = Widget->IsDragging();
			Widget->SetDragging(false);

#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayClusterConfigurator/Private/Views/Viewport/DisplayClusterConfiguratorSCSEditorViewportClient.cpp:914

Scope (from outer to inner):

file
function     HHitProxy* FDisplayClusterConfiguratorSCSEditorViewportClient::GetHitProxyWithoutGizmos

Source code excerpt:

	if (HitProxy->IsA(HWidgetAxis::StaticGetType()))
	{
		const bool bOldModeWidgets = EngineShowFlags.ModeWidgets;

		EngineShowFlags.SetModeWidgets(false);
		bool bWasWidgetDragging = Widget->IsDragging();
		Widget->SetDragging(false);

		// Invalidate the hit proxy map so it will be rendered out again when GetHitProxy

#Loc: <Workspace>/Engine/Source/Editor/Experimental/EditorInteractiveToolsFramework/Private/EditorGizmos/EditorTransformGizmo.cpp:18

Scope (from outer to inner):

file
function     void UEditorTransformGizmo::Render

Source code excerpt:

	const FSceneView* SceneView = RenderAPI ? RenderAPI->GetSceneView() : nullptr;
	const bool bEngineShowFlagsModeWidget = SceneView && SceneView->Family &&
											SceneView->Family->EngineShowFlags.ModeWidgets;
	if (bEngineShowFlagsModeWidget)
	{
		Super::Render(RenderAPI);
	}
}

#Loc: <Workspace>/Engine/Source/Editor/Experimental/EditorInteractiveToolsFramework/Private/EditorInteractiveGizmoManager.cpp:219

Scope (from outer to inner):

file
function     bool UEditorInteractiveGizmoManager::GetShowEditorGizmosForView

Source code excerpt:

	const bool bEngineShowFlagsModeWidget = (RenderAPI && RenderAPI->GetSceneView() && 
											 RenderAPI->GetSceneView()->Family &&
											 RenderAPI->GetSceneView()->Family->EngineShowFlags.ModeWidgets);
	return bShowEditorGizmos && bEngineShowFlagsModeWidget;
}

void UEditorInteractiveGizmoManager::UpdateActiveEditorGizmos()
{
	const bool bEnableEditorGizmos = UsesNewTRSGizmos();

#Loc: <Workspace>/Engine/Source/Editor/Kismet/Private/SCSEditorViewportClient.cpp:371

Scope (from outer to inner):

file
function     void FSCSEditorViewportClient::ProcessClick

Source code excerpt:

		else if (HitProxy->IsA(HWidgetAxis::StaticGetType()))
		{
			const bool bOldModeWidgets1 = EngineShowFlags.ModeWidgets;
			const bool bOldModeWidgets2 = View.Family->EngineShowFlags.ModeWidgets;

			EngineShowFlags.SetModeWidgets(false);
			FSceneViewFamily* SceneViewFamily = const_cast<FSceneViewFamily*>(View.Family);
			SceneViewFamily->EngineShowFlags.SetModeWidgets(false);
			bool bWasWidgetDragging = Widget->IsDragging();
			Widget->SetDragging(false);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorModeManager.cpp:1567

Scope (from outer to inner):

file
function     void FEditorModeTools::DrawHUD

Source code excerpt:

	DrawBrackets(InViewportClient, Viewport, View, Canvas);

	if (!(InViewportClient->EngineShowFlags.ModeWidgets))
	{
		return;
	}

	// Clear Hit proxies
	const bool bIsHitTesting = Canvas->IsHitTesting();

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/LevelEditorViewport.cpp:1413

Scope (from outer to inner):

file
function     bool FLevelEditorViewportClient::DropObjectsOnWidget

Source code excerpt:

	// Modify the ShowFlags for the scene so we can re-render the hit proxies without any axis widgets. 
	// Store original ShowFlags and assign them back when we're done
	const bool bOldModeWidgets1 = EngineShowFlags.ModeWidgets;
	const bool bOldModeWidgets2 = View->Family->EngineShowFlags.ModeWidgets;

	EngineShowFlags.SetModeWidgets(false);
	FSceneViewFamily* SceneViewFamily = const_cast< FSceneViewFamily* >( View->Family );
	SceneViewFamily->EngineShowFlags.SetModeWidgets(false);

	// Invalidate the hit proxy map so it will be rendered out again when GetHitProxy is called

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/LevelEditorViewport.cpp:2832

Scope (from outer to inner):

file
function     void FLevelEditorViewportClient::ProcessClick

Source code excerpt:

			// for the scene so we can re-render the hit proxies without any axis widgets.  We'll
			// store the original ShowFlags and modify them appropriately
			const bool bOldModeWidgets1 = EngineShowFlags.ModeWidgets;
			const bool bOldModeWidgets2 = View.Family->EngineShowFlags.ModeWidgets;

			EngineShowFlags.SetModeWidgets(false);
			FSceneViewFamily* SceneViewFamily = const_cast<FSceneViewFamily*>(View.Family);
			SceneViewFamily->EngineShowFlags.SetModeWidgets(false);
			bool bWasWidgetDragging = Widget->IsDragging();
			Widget->SetDragging(false);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/UnrealWidgetRender.cpp:180

Scope (from outer to inner):

file
function     void FWidget::Render

Source code excerpt:

	HUDString.Empty();

	const bool bShowFlagsSupportsWidgetDrawing = View->Family->EngineShowFlags.ModeWidgets;
	const bool bEditorModeToolsSupportsWidgetDrawing = EditorModeTools ? EditorModeTools->GetShowWidget() : true;

	// Use legacy widget for TranslateRotateZ or 2D modes or when UseLegacyWidget cvar is true
	UE::Widget::EWidgetMode WidgetMode = ViewportClient->GetWidgetMode();
	bool bUseLegacyWidget = (WidgetMode == UE::Widget::EWidgetMode::WM_TranslateRotateZ || WidgetMode == UE::Widget::EWidgetMode::WM_2D);
	if (!bUseLegacyWidget)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:255

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(0, EditingLevelInstance, SFG_Transient, NSLOCTEXT("UnrealEd", "EditingLevelInstanceSF", "Editing LevelInstance"))
/** Draws mode specific widgets and controls in the viewports (should only be set on viewport clients that are editing the level itself) */
SHOWFLAG_FIXED_IN_SHIPPING(0, ModeWidgets, SFG_Advanced, NSLOCTEXT("UnrealEd", "ModeWidgetsSF", "Mode Widgets"))
/**  */
SHOWFLAG_FIXED_IN_SHIPPING(0, Bounds,  SFG_Advanced, NSLOCTEXT("UnrealEd", "BoundsSF", "Bounds"))
/** Draws each hit proxy in the scene with a different color, for now only available in the editor */
SHOWFLAG_FIXED_IN_SHIPPING(0, HitProxies, SFG_Developer, NSLOCTEXT("UnrealEd", "HitProxiesSF", "Hit Proxies"))
/** Draw lines to lights affecting this mesh if its selected. */
SHOWFLAG_FIXED_IN_SHIPPING(0, LightInfluences, SFG_Advanced, NSLOCTEXT("UnrealEd", "LightInfluencesSF", "Light Influences"))