TSharedRef< SWidget > SDesignerToolBar::MakeToolBar(const TSharedPtr< FExtender > InExtenders)
{
	FToolBarBuilder ToolbarBuilder( CommandList, FMultiBoxCustomization::None, InExtenders );

	// Use a custom style
	FName ToolBarStyle = "ViewportMenu";
	ToolbarBuilder.SetStyle(&FEditorStyle::Get(), ToolBarStyle);
	ToolbarBuilder.SetLabelVisibility(EVisibility::Collapsed);

	// Transform controls cannot be focusable as it fights with the press space to change transform mode feature
	ToolbarBuilder.SetIsFocusable( false );

	ToolbarBuilder.BeginSection("View");
	ToolbarBuilder.AddToolBarButton(FDesignerCommands::Get().ToggleOutlines, NAME_None, TAttribute<FText>(), TAttribute<FText>(), TAttribute<FSlateIcon>(), "ToggleOutlines");
	ToolbarBuilder.EndSection();

	ToolbarBuilder.BeginSection("Transform");
	ToolbarBuilder.BeginBlockGroup();
	{
		ToolbarBuilder.AddToolBarButton( FDesignerCommands::Get().LayoutTransform, NAME_None, TAttribute<FText>(), TAttribute<FText>(), TAttribute<FSlateIcon>(), "LayoutTransform" );
		ToolbarBuilder.AddToolBarButton( FDesignerCommands::Get().RenderTransform, NAME_None, TAttribute<FText>(), TAttribute<FText>(), TAttribute<FSlateIcon>(), "RenderTransform" );
	}
	ToolbarBuilder.EndBlockGroup();
	ToolbarBuilder.EndSection();

	ToolbarBuilder.BeginSection("LocationGridSnap");
	{
		// Grab the existing UICommand 
		FUICommandInfo* Command = FDesignerCommands::Get().LocationGridSnap.Get();

		static FName PositionSnapName = FName(TEXT("PositionSnap"));

		// Setup a GridSnapSetting with the UICommand
		ToolbarBuilder.AddWidget(SNew(SViewportToolBarComboMenu)
			.Style(ToolBarStyle)
			.BlockLocation(EMultiBlockLocation::Start)
			.Cursor(EMouseCursor::Default)
			.IsChecked(this, &SDesignerToolBar::IsLocationGridSnapChecked)
			.OnCheckStateChanged(this, &SDesignerToolBar::HandleToggleLocationGridSnap)
			.Label(this, &SDesignerToolBar::GetLocationGridLabel)
			.OnGetMenuContent(this, &SDesignerToolBar::FillLocationGridSnapMenu)
			.ToggleButtonToolTip(Command->GetDescription())
			.MenuButtonToolTip(LOCTEXT("LocationGridSnap_ToolTip", "Set the Position Grid Snap value"))
			.Icon(Command->GetIcon())
			.ParentToolBar(SharedThis(this))
			, PositionSnapName);
	}
	ToolbarBuilder.EndSection();
	
	return ToolbarBuilder.MakeWidget();
}
예제 #2
0
void FUserDefinedGestures::SetUserDefinedGesture( const FUICommandInfo& CommandInfo )
{
	if( Gestures.IsValid() )
	{
		const FName BindingContext = CommandInfo.GetBindingContext();
		const FName CommandName = CommandInfo.GetCommandName();

		// Find or create the command context
		const FUserDefinedGestureKey GestureKey(BindingContext, CommandName);
		FInputGesture& UserDefinedGesture = Gestures->FindOrAdd(GestureKey);

		// Save an empty invalid gesture if one was not set
		// This is an indication that the user doesn't want this bound and not to use the default gesture
		const TSharedPtr<const FInputGesture> InputGesture = CommandInfo.GetActiveGesture();
		UserDefinedGesture = (InputGesture.IsValid()) ? *InputGesture : FInputGesture();
	}
}
void FUserDefinedChords::SetUserDefinedChord( const FUICommandInfo& CommandInfo )
{
	if( Chords.IsValid() )
	{
		const FName BindingContext = CommandInfo.GetBindingContext();
		const FName CommandName = CommandInfo.GetCommandName();

		// Find or create the command context
		const FUserDefinedChordKey ChordKey(BindingContext, CommandName);
		FInputChord& UserDefinedChord = Chords->FindOrAdd(ChordKey);

		// Save an empty invalid chord if one was not set
		// This is an indication that the user doesn't want this bound and not to use the default chord
		const TSharedPtr<const FInputChord> InputChord = CommandInfo.GetActiveChord();
		UserDefinedChord = (InputChord.IsValid()) ? *InputChord : FInputChord();
	}
}
예제 #4
0
void FInputBindingManager::NotifyActiveGestureChanged( const FUICommandInfo& CommandInfo )
{
	FContextEntry& ContextEntry = ContextMap.FindChecked( CommandInfo.GetBindingContext() );

	// Slow but doesn't happen frequently
	for( FGestureMap::TIterator It( ContextEntry.GestureToCommandInfoMap ); It; ++It )
	{
		// Remove the currently active gesture from the map if one exists
		if( It.Value() == CommandInfo.GetCommandName() )
		{
			It.RemoveCurrent();
			// There should only be one active gesture
			break;
		}
	}

	if( CommandInfo.GetActiveGesture()->IsValidGesture() )
	{
		checkSlow( !ContextEntry.GestureToCommandInfoMap.Contains( *CommandInfo.GetActiveGesture() ) )
		ContextEntry.GestureToCommandInfoMap.Add( *CommandInfo.GetActiveGesture(), CommandInfo.GetCommandName() );
	}
	

	// The user defined gestures should have already been created
	check( UserDefinedGestures.IsValid() );

	UserDefinedGestures->SetUserDefinedGesture( CommandInfo );

	// Broadcast the gesture event when a new one is added
	OnUserDefinedGestureChanged.Broadcast(CommandInfo);
}