FReply SGraphPinColor::OnColorBoxClicked(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
	if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
	{
		SelectedColor = GetColor();
		TArray<FLinearColor*> LinearColorArray;
		LinearColorArray.Add(&SelectedColor);

		FColorPickerArgs PickerArgs;
		PickerArgs.bIsModal = true;
		PickerArgs.ParentWidget = AsShared();
		PickerArgs.DisplayGamma = TAttribute<float>::Create(TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma));
		PickerArgs.LinearColorArray = &LinearColorArray;
		PickerArgs.OnColorCommitted = FOnLinearColorValueChanged::CreateSP(this, &SGraphPinColor::OnColorCommitted);
		PickerArgs.bUseAlpha = true;

		OpenColorPicker(PickerArgs);

		return FReply::Handled();
	}
	else
	{
		return FReply::Unhandled();
	}
}
void FPathContextMenu::ExecutePickColor()
{
	// Spawn a color picker, so the user can select which color they want
	TArray<FLinearColor*> LinearColorArray;
	FColorPickerArgs PickerArgs;
	PickerArgs.bIsModal = false;
	PickerArgs.ParentWidget = ParentContent.Pin();
	if ( SelectedPaths.Num() > 0 )
	{
		// Make sure an color entry exists for all the paths, otherwise they won't update in realtime with the widget color
		for (int32 PathIdx = SelectedPaths.Num() - 1; PathIdx >= 0; --PathIdx)
		{
			const FString& Path = SelectedPaths[PathIdx];
			TSharedPtr<FLinearColor> Color = ContentBrowserUtils::LoadColor( Path );
			if ( !Color.IsValid() )
			{
				Color = MakeShareable( new FLinearColor( ContentBrowserUtils::GetDefaultColor() ) );
				ContentBrowserUtils::SaveColor( Path, Color, true );
			}
			else
			{
				// Default the color to the first valid entry
				PickerArgs.InitialColorOverride = *Color.Get();
			}
			LinearColorArray.Add( Color.Get() );
		}	
		PickerArgs.LinearColorArray = &LinearColorArray;
	}
		
	PickerArgs.OnColorPickerWindowClosed = FOnWindowClosed::CreateSP(this, &FPathContextMenu::NewColorComplete);

	OpenColorPicker(PickerArgs);
}
Ejemplo n.º 3
0
void SColorGradientEditor::OpenGradientStopColorPicker()
{
	TArray<FRichCurveEditInfo> Curves = CurveOwner->GetCurves();

	if( SelectedStop.IsValidAlphaMark( Curves ) )
	{
		// Show a slider to change the alpha value
		TSharedRef<SWidget> AlphaSlider = 
		SNew( SBorder )
		.BorderImage( FEditorStyle::GetBrush("Menu.Background") )
		[
			SNew( SVerticalBox )
			+ SVerticalBox::Slot()
			[
				SNew( STextBlock )
				.Text( LOCTEXT("AlphaLabel","Opacity") )
				.TextStyle( FEditorStyle::Get(), "Menu.Heading" )
			]
			+ SVerticalBox::Slot()
			.Padding( 3.0f, 2.0f, 3.0f, 5.0f )
			.AutoHeight()
			[
				SNew( SBox )
				.WidthOverride( 100.0f )
				[
					SNew( SSpinBox<float> )
					.MinSliderValue(0.0f)
					.MaxSliderValue(1.0f)
					.MinValue(-FLT_MAX)
					.MaxValue(FLT_MAX)
					.Value( SelectedStop.GetColor( *CurveOwner ).A )
					.OnBeginSliderMovement( this, &SColorGradientEditor::OnBeginChangeAlphaValue )
					.OnEndSliderMovement( this, &SColorGradientEditor::OnEndChangeAlphaValue )
					.OnValueChanged( this, &SColorGradientEditor::OnAlphaValueChanged )
					.OnValueCommitted( this, &SColorGradientEditor::OnAlphaValueCommitted )
				]
			]
		];

		FSlateApplication::Get().PushMenu( SharedThis( this ), AlphaSlider, ContextMenuPosition, FPopupTransitionEffect::TypeInPopup );
	}
	else
	{
		// Open a color picker
		FColorPickerArgs ColorPickerArgs;

		ColorPickerArgs.bOnlyRefreshOnMouseUp = false;
		ColorPickerArgs.bIsModal = false;
		ColorPickerArgs.ParentWidget = SharedThis( this );
		ColorPickerArgs.bUseAlpha = false;
		ColorPickerArgs.InitialColorOverride = SelectedStop.GetColor( *CurveOwner );
		ColorPickerArgs.OnColorCommitted = FOnLinearColorValueChanged::CreateSP( this, &SColorGradientEditor::OnSelectedStopColorChanged );
		ColorPickerArgs.OnColorPickerCancelled  = FOnColorPickerCancelled::CreateSP( this, &SColorGradientEditor::OnCancelSelectedStopColorChange );
		OpenColorPicker( ColorPickerArgs );
	}
}
void SPropertyEditorColor::CreateColorPickerWindow(const TSharedRef< class FPropertyEditor >& InPropertyEditor, bool bUseAlpha, bool bOnlyRefreshOnOk)
{
	const TSharedRef< FPropertyNode > PropertyNode = InPropertyEditor->GetPropertyNode();

	UProperty* Property = PropertyNode->GetProperty();
	check(Property);

	FReadAddressList ReadAddresses;
	PropertyNode->GetReadAddress( false, ReadAddresses, false );

	FLinearColor InitialColor = FLinearColor(ForceInit);
	if( ReadAddresses.Num() )
	{
		OriginalColors.Empty( ReadAddresses.Num() );
		OriginalColors.AddUninitialized( ReadAddresses.Num() );

		// Store off the original colors in the case that the user cancels the color picker. We'll revert to the original colors in that case
		for( int32 AddrIndex = 0; AddrIndex <  ReadAddresses.Num(); ++AddrIndex )
		{
		
			const uint8* Addr = ReadAddresses.GetAddress(AddrIndex);
			if( Addr )
			{
				if( Cast<UStructProperty>(Property)->Struct->GetFName() == NAME_Color )
				{
					OriginalColors[AddrIndex] = ((FColor*)Addr)->ReinterpretAsLinear();
				}
				else
				{
					check( Cast<UStructProperty>(Property)->Struct->GetFName() == NAME_LinearColor );
					OriginalColors[AddrIndex] = *(FLinearColor*)Addr;
				}
			}
		}

		// Only one color can be the initial color.  Just use the first color property
		InitialColor = OriginalColors[0];

		FColorPickerArgs PickerArgs;
		PickerArgs.bOnlyRefreshOnMouseUp = true;
		PickerArgs.ParentWidget = AsShared();
		PickerArgs.bUseAlpha = bUseAlpha;
		PickerArgs.bOnlyRefreshOnOk = bOnlyRefreshOnOk;
		PickerArgs.DisplayGamma = TAttribute<float>::Create( TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma) );
		PickerArgs.OnColorCommitted = FOnLinearColorValueChanged::CreateSP( this, &SPropertyEditorColor::SetColor);
		PickerArgs.OnColorPickerCancelled = FOnColorPickerCancelled::CreateSP( this, &SPropertyEditorColor::OnColorPickerCancelled );
		PickerArgs.InitialColorOverride = InitialColor;

		OpenColorPicker(PickerArgs);
	}
	

}
void FSequencerFolderNode::SetFolderColor()
{
	InitialFolderColor = MovieSceneFolder.GetFolderColor();
	bFolderPickerWasCancelled = false;

	FColorPickerArgs PickerArgs;
	PickerArgs.bUseAlpha = false;
	PickerArgs.DisplayGamma = TAttribute<float>::Create( TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma) );
	PickerArgs.InitialColorOverride = InitialFolderColor.ReinterpretAsLinear();
	PickerArgs.OnColorCommitted = FOnLinearColorValueChanged::CreateSP( this, &FSequencerFolderNode::OnColorPickerPicked);
	PickerArgs.OnColorPickerWindowClosed = FOnWindowClosed::CreateSP( this, &FSequencerFolderNode::OnColorPickerClosed);
	PickerArgs.OnColorPickerCancelled  = FOnColorPickerCancelled::CreateSP( this, &FSequencerFolderNode::OnColorPickerCancelled );

	OpenColorPicker(PickerArgs);
}
Ejemplo n.º 6
0
void FLevelViewModel::ChangeColor(const TSharedRef<SWidget>& InPickerParentWidget)
{
	if( !Level.IsValid() )
	{
		return;
	}

	if ( !Level->IsPersistentLevel())
	{
		// Initialize the color data for the picker window.
		ULevelStreaming* StreamingLevel = FLevelUtils::FindStreamingLevel( Level.Get() );
		check( StreamingLevel );

		FLinearColor NewColor = StreamingLevel->LevelColor;
		TArray<FLinearColor*> ColorArray;
		ColorArray.Add(&NewColor);

		FColorPickerArgs PickerArgs;
		PickerArgs.bIsModal = true;
		PickerArgs.DisplayGamma = TAttribute<float>::Create( TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma) );
		PickerArgs.LinearColorArray = &ColorArray;
		PickerArgs.OnColorPickerCancelled = FOnColorPickerCancelled::CreateSP(this, &FLevelViewModel::OnColorPickerCancelled);
		PickerArgs.ParentWidget = InPickerParentWidget;

		// ensure this is true, will be set to false in OnColorPickerCancelled if necessary
		bColorPickerOK = true;
		if (OpenColorPicker(PickerArgs))
		{
			if ( bColorPickerOK )
			{
				StreamingLevel->LevelColor = NewColor;
				StreamingLevel->Modify();

				// Update the loaded level's components so the change in color will apply immediately
				ULevel* LoadedLevel = StreamingLevel->GetLoadedLevel();
				if ( LoadedLevel )
				{
					LoadedLevel->UpdateLevelComponents(false);
				}

				ULevel::LevelDirtiedEvent.Broadcast();
			}
			FEditorSupportDelegates::RedrawAllViewports.Broadcast();
		}
	}
}
void FReplaceVectorWithLinearColorBuilder::CreateColorPicker(const TSharedPtr<IPropertyHandle>& StructHandle)
{
	OldColorValue = GetColorValue(StructHandle);

	FColorPickerArgs PickerArgs;
	PickerArgs.bUseAlpha = false;
	PickerArgs.bOnlyRefreshOnMouseUp = false;
	PickerArgs.bOnlyRefreshOnOk = false;
	PickerArgs.DisplayGamma = TAttribute<float>::Create(TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma));
	PickerArgs.OnColorCommitted = FOnLinearColorValueChanged::CreateSP(this, &FReplaceVectorWithLinearColorBuilder::OnSetColorFromColorPicker, StructHandle);
	PickerArgs.OnColorPickerCancelled = FOnColorPickerCancelled::CreateSP(this, &FReplaceVectorWithLinearColorBuilder::OnColorPickerCancelled, StructHandle);
	PickerArgs.OnInteractivePickBegin = FSimpleDelegate::CreateSP(this, &FReplaceVectorWithLinearColorBuilder::OnColorPickerInteractiveBegin);
	PickerArgs.OnInteractivePickEnd = FSimpleDelegate::CreateSP(this, &FReplaceVectorWithLinearColorBuilder::OnColorPickerInteractiveEnd);
	PickerArgs.InitialColorOverride = OldColorValue;
	PickerArgs.ParentWidget = ColorPickerParentWidget;

	OpenColorPicker(PickerArgs);
}
void FColorStructCustomization::CreateColorPicker( bool bUseAlpha, bool bOnlyRefreshOnOk )
{
	int32 NumObjects = StructPropertyHandle->GetNumOuterObjects();

	SavedPreColorPickerColors.Empty();
	TArray<FString> PerObjectValues;
	StructPropertyHandle->GetPerObjectValues( PerObjectValues );

	for( int32 ObjectIndex = 0; ObjectIndex < NumObjects; ++ObjectIndex )
	{
		if( bIsLinearColor )
		{
			FLinearColor Color;
			Color.InitFromString( PerObjectValues[ObjectIndex] );
			SavedPreColorPickerColors.Add( Color );	
		}
		else
		{
			FColor Color;
			Color.InitFromString( PerObjectValues[ObjectIndex] );
			SavedPreColorPickerColors.Add( Color.ReinterpretAsLinear() );
		}
	}

	FLinearColor InitialColor;
	GetColorAsLinear(InitialColor);

	// This needs to be meta data.  Other colors could benefit from this
	const bool bRefreshOnlyOnOk = StructPropertyHandle->GetProperty()->GetOwnerClass()->IsChildOf(UMaterialExpressionConstant3Vector::StaticClass());

	FColorPickerArgs PickerArgs;
	PickerArgs.bUseAlpha = !bIgnoreAlpha;
	PickerArgs.bOnlyRefreshOnMouseUp = false;
	PickerArgs.bOnlyRefreshOnOk = bRefreshOnlyOnOk;
	PickerArgs.DisplayGamma = TAttribute<float>::Create( TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma) );
	PickerArgs.OnColorCommitted = FOnLinearColorValueChanged::CreateSP( this, &FColorStructCustomization::OnSetColorFromColorPicker );
	PickerArgs.OnColorPickerCancelled = FOnColorPickerCancelled::CreateSP( this, &FColorStructCustomization::OnColorPickerCancelled );
	PickerArgs.OnInteractivePickBegin = FSimpleDelegate::CreateSP( this, &FColorStructCustomization::OnColorPickerInteractiveBegin );
	PickerArgs.OnInteractivePickEnd = FSimpleDelegate::CreateSP( this, &FColorStructCustomization::OnColorPickerInteractiveEnd );
	PickerArgs.InitialColorOverride = InitialColor;
	PickerArgs.ParentWidget = ColorPickerParentWidget;

	OpenColorPicker(PickerArgs);
}
Ejemplo n.º 9
0
/**
* Creates the color picker window for this property view.
*
* @param Node				The slate property node to edit.
* @param bUseAlpha			Whether or not alpha is supported
*/
void SDetailsViewBase::CreateColorPickerWindow(const TSharedRef< FPropertyEditor >& PropertyEditor, bool bUseAlpha)
{
	const TSharedRef< FPropertyNode > PinnedColorPropertyNode = PropertyEditor->GetPropertyNode();
	ColorPropertyNode = PinnedColorPropertyNode;

	UProperty* Property = PinnedColorPropertyNode->GetProperty();
	check(Property);

	FReadAddressList ReadAddresses;
	PinnedColorPropertyNode->GetReadAddress(false, ReadAddresses, false);

	TArray<FLinearColor*> LinearColor;
	TArray<FColor*> DWORDColor;
	for (int32 ColorIndex = 0; ColorIndex < ReadAddresses.Num(); ++ColorIndex)
	{
		const uint8* Addr = ReadAddresses.GetAddress(ColorIndex);
		if (Addr)
		{
			if (Cast<UStructProperty>(Property)->Struct->GetFName() == NAME_Color)
			{
				DWORDColor.Add((FColor*)Addr);
			}
			else
			{
				check(Cast<UStructProperty>(Property)->Struct->GetFName() == NAME_LinearColor);
				LinearColor.Add((FLinearColor*)Addr);
			}
		}
	}

	bHasOpenColorPicker = true;

	FColorPickerArgs PickerArgs;
	PickerArgs.ParentWidget = AsShared();
	PickerArgs.bUseAlpha = bUseAlpha;
	PickerArgs.DisplayGamma = TAttribute<float>::Create(TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma));
	PickerArgs.ColorArray = &DWORDColor;
	PickerArgs.LinearColorArray = &LinearColor;
	PickerArgs.OnColorCommitted = FOnLinearColorValueChanged::CreateSP(this, &SDetailsViewBase::SetColorPropertyFromColorPicker);
	PickerArgs.OnColorPickerWindowClosed = FOnWindowClosed::CreateSP(this, &SDetailsViewBase::OnColorPickerWindowClosed);

	OpenColorPicker(PickerArgs);
}
Ejemplo n.º 10
0
void SSingleProperty::CreateColorPickerWindow( const TSharedRef< class FPropertyEditor >& PropertyEditor, bool bUseAlpha )
{
	if( HasValidProperty() )
	{
		auto Node = PropertyEditor->GetPropertyNode();
		check( &Node.Get() == ValueNode.Get() );
		UProperty* Property = Node->GetProperty();
		check(Property);

		FReadAddressList ReadAddresses;
		Node->GetReadAddress( false, ReadAddresses, false );

		TArray<FLinearColor*> LinearColor;
		TArray<FColor*> DWORDColor;
		if( ReadAddresses.Num() ) 
		{
			const uint8* Addr = ReadAddresses.GetAddress(0);
			if( Addr )
			{
				if( Cast<UStructProperty>(Property)->Struct->GetFName() == NAME_Color )
				{
					DWORDColor.Add((FColor*)Addr);
				}
				else
				{
					check( Cast<UStructProperty>(Property)->Struct->GetFName() == NAME_LinearColor );
					LinearColor.Add((FLinearColor*)Addr);
				}
			}
		}

		FColorPickerArgs PickerArgs;
		PickerArgs.ParentWidget = AsShared();
		PickerArgs.bUseAlpha = bUseAlpha;
		PickerArgs.DisplayGamma = TAttribute<float>::Create( TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma) );
		PickerArgs.ColorArray = &DWORDColor;
		PickerArgs.LinearColorArray = &LinearColor;
		PickerArgs.OnColorCommitted = FOnLinearColorValueChanged::CreateSP( this, &SSingleProperty::SetColorPropertyFromColorPicker);

		OpenColorPicker(PickerArgs);
	}
}
Ejemplo n.º 11
0
FReply SWorldHierarchyItem::OnChangeColor()
{
	if (LevelModel.IsValid())
	{
		FColorPickerArgs PickerArgs;
		PickerArgs.DisplayGamma = TAttribute<float>::Create(TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma));
		PickerArgs.InitialColorOverride = LevelModel->GetLevelColor();
		PickerArgs.bOnlyRefreshOnMouseUp = false;
		PickerArgs.bOnlyRefreshOnOk = false;
		PickerArgs.OnColorCommitted = FOnLinearColorValueChanged::CreateSP(this, &SWorldHierarchyItem::OnSetColorFromColorPicker);
		PickerArgs.OnColorPickerCancelled = FOnColorPickerCancelled::CreateSP(this, &SWorldHierarchyItem::OnColorPickerCancelled);
		PickerArgs.OnInteractivePickBegin = FSimpleDelegate::CreateSP(this, &SWorldHierarchyItem::OnColorPickerInteractiveBegin);
		PickerArgs.OnInteractivePickEnd = FSimpleDelegate::CreateSP(this, &SWorldHierarchyItem::OnColorPickerInteractiveEnd);
		PickerArgs.ParentWidget = AsShared();

		OpenColorPicker(PickerArgs);
	}

	return FReply::Handled();
}
Ejemplo n.º 12
0
void
EditButtonWindow::MessageReceived(BMessage *msg)
{
	BMessage mymsg(51000);
	int32 id,vl;
	BTextControl *xt = NULL;
	char *txt = "";
	WrkWindow *win = DefWin,*wi = OldWindow;

	msg->FindInt32("be:value",&vl);
	msg->FindInt32("index",&id);

	if (msg->FindPointer("source",(void **)&xt) == B_OK)
	{
		if (is_instance_of(xt,BTextControl))
		{
			txt = xt->Text();		
		}	
	}

	switch(msg->what)
	{
		case	73500:
		case	73501:
		case	73502:
		{
			CheckItemBox *it;
			int k;

			for (k = 0; k < idcmp->CountItems(); k++)
			{
				if (it = (CheckItemBox *)idcmp->ItemAt(k))
				{
					switch(msg->what)
					{
						case	73500:	it->checked = true;		break;
						case	73501:	it->checked = false;	break;
						case	73502:	it->checked = !it->checked;	break;
					}

					ChangeFlags(k,it->checked);

					idcmp->InvalidateItem(idcmp->IndexOf(it));
				}			
			}
		}
		break;

		case	73600:
		case	73601:
		case	73602:
		{
			CheckItemBox *it;
			int k;

			for (k = 0; k < lv->CountItems(); k++)
			{
				if (it = (CheckItemBox *)lv->ItemAt(k))
				{
					switch(msg->what)
					{
						case	73600:	it->checked = true;		break;
						case	73601:	it->checked = false;	break;
						case	73602:	it->checked = !it->checked;	break;
					}

					ChangeView(k,it->checked);

					lv->InvalidateItem(lv->IndexOf(it));
				}			
			}
		}
		break;

		case	2200:
		{
			OpenColorPicker(msg);
		}
		break;

		case BEAIM_NEW_COLOR_PICKED:
		{
			ColorView *bt;

			if (msg->FindPointer("pt",(void **)&bt) == B_OK)
			{
				rgb_color cl,*startColor;
				ssize_t size;
	
				msg->FindData( "color",B_RGB_COLOR_TYPE,(const void**)&startColor,&size );

				cl.red 		= startColor->red;
				cl.green 	= startColor->green;
				cl.blue 	= startColor->blue;

				bt->SetColor(cl);
			}

			SetNewColor(msg);
		}
		break;	

		case	tab_tab_list:
		{
			AddListWindow(win->sellist.ItemAt(0));
		}
		break;

		case	tab_menu_list:
		{
			create_mmxmenu();
		}
		break;

		case	tab_menu_editlist:
		{
			struct MyGadget *gad;

			if (gad = win->sellist.ItemAt(0))
			{
				window_menu(&gad->name);
			}
		}
		break;

		case	window_minh:
		{
			if (wi)
			{
				wi->minh = vl;			
			}
		}
		break;

		case	window_maxh:
		{
			if (wi)
			{
				wi->maxh = vl;			
			}
		}
		break;

		case	window_minw:
		{
			if (wi)
			{
				wi->minw = vl;			
			}
		}
		break;

		case	window_maxw:
		{
			if (wi)
			{
				wi->maxw = vl;			
			}
		}
		break;

		case	tab_font:
		{
			struct MyGadget *gad;

			if (wi = win)
			{
				if (gad = win->sellist.ItemAt(0))
				{
					font_window(gad->FontType,gad->FontSize,gad->FontAntiliasing,&gad->FontName[0],&gad->FontStyle[0]);
				}
					else
				{
					font_window(wi->FontType,wi->FontSize,wi->FontAntiliasing,&wi->FontName[0],&wi->FontStyle[0]);
				}
			}		
		}
		break;

		case	window_type:
		{
			if (wi)
			{
				wi->typewin = id;			

				ChangeWindowType(wi,id);
			}
		}
		break;

		case	window_look:
		{
			if (wi)
			{
				wi->look = id;			
			}
		}
		break;

		case	window_feel:
		{
			if (wi)
			{
				wi->feel = id;			
			}
		}
		break;

		case	window_workspace:
		{
			if (wi)
			{
				wi->wrk = id;			
			}
		}
		break;
			
		case	9000:
		{
			mymsg.AddInt32("x",vl);	
	
			win->PostMessage(&mymsg);
		}
		break;

		case	9001:
		{
			mymsg.AddInt32("y",vl);	
	
			win->PostMessage(&mymsg);
		}
		break;

		case	9002:
		{
			mymsg.AddInt32("w",vl);	
	
			win->PostMessage(&mymsg);
		}
		break;

		case	9003:
		{
			mymsg.AddInt32("h",vl);	
	
			win->PostMessage(&mymsg);
		}
		break;

		case	9004:
		{
			if (strcmp(txt,"") != 0)
			{
				if (is_title_available(txt))
				{
					if (win)
					{
						if (gad = win->sellist.ItemAt(0))
						{
							strcpy(&gad->Name[0],txt);		
						}
							else
						{
							strcpy(&win->Name[0],txt);		
						}
					}
				}
					else
				{
err:				if (EditorWin)
					{
						BAutolock lock(EditorWin);

						if (win)
						{
							if (gad = win->sellist.ItemAt(0))
							{
								EditorWin->name->SetText(&gad->Name[0]);
							}
								else
							{
								EditorWin->name->SetText(&win->Name[0]);
							}
						}	
					}	
				}	
			}
				else
			{
				::beep();
				
				goto err;
			}	
		}
		break;

		case	9005:
		{
			if (win)
			{
				if (gad = win->sellist.ItemAt(0))
				{
					strcpy(&gad->Title[0],txt);		

					ChangeGadgetLabel(gad,txt);
				}
					else
				{
					strcpy(&win->WTitle[0],txt);		

					win->Lock();

					win->ChangeTitleWindow();

					win->Unlock();
				}
			}	
		}
		break;

		case	9006:
		{
			if (gad)
			{
				gad->msg = atoi(txt);
			}
		}
		break;

		case	tab_focus:
		{
			gad->focus = id;		
		}
		break;

		case	align_type:
		{
			if (id == 2)
			{
				EnableRadio(true);

				SetChoiceInMenu(alignx->Menu(),gad->alignx,true);
				SetChoiceInMenu(aligny->Menu(),gad->aligny,true);

			}
				else
			{
				EnableRadio(false);
			}	

			gad->align = id;
		}
		break;
		
		case	align_x:
		{
			gad->alignx = id;
		}
		break;	

		case	align_y:
		{
			gad->aligny = id;
		}
		break;	

		case	gad_derived:
		{
			gad->derived = vl;
		}
		break;

//**************************** BUTTON *****************

		case	tab_button_default:
		{
			gad->data.button.defaut = id;

			set_button_defaut(gad,id);
		}
		break;

		case	tab_button_enabled:
		case	tab_checkbox_enabled:
		{
			gad->enable = id;

			SetEnableGadget(gad,id);
		}
		break;

//**************************** BBOX *****************

		case	tab_bbox_border:
		{
			gad->data.bbox.style = id;

			set_bbox_border(gad,id);
		}
		break;

		case	tab_bbox_label:
		{
			strcpy(&gad->data.bbox.Label[0],txt);

			set_bbox_label(gad,txt);		
		}
		break;

//**************************** CHECKBOX *****************

		case	tab_checkbox_checked:
		{
			gad->data.bcheckbox.checked = id;

			set_checkbox_checked(gad,id);
		}
		break;

//**************************** RADIO *****************

		case	tab_radio_value:
		{
			gad->data.rad.val = id;

			set_radio_checked(gad,id);
		}
		break;

		case	tab_radio_enable:
		{
			gad->enable = id;

			set_radio_enabled(gad,id);
		}
		break;

//**************************** STRING *****************

		case	tab_string_alignlab:
		{
			gad->data.string.alignlab = id;

			set_string_alignment_label(gad,id);		
		}
		break;

		case	tab_string_aligntxt:
		{
			gad->data.string.aligntxt = id;

			set_string_alignment_text(gad,id);		
		}
		break;

		case	tab_string_diviser:
		{
			gad->data.string.pixdiv = vl;

			set_string_divider(gad,vl);		
		}
		break;

		case	tab_string_label:
		{
			strcpy(&gad->data.string.Text[0],txt);

			set_string_label(gad,txt);		
		}
		break;

//**************************** STATUS *****************

		case	tab_status_trail:
		{
			strcpy(&gad->data.sta.Trail[0],txt);

			set_status_label(gad,txt);		
		}
		break;

		case	tab_status_label:
		{
			strcpy(&gad->data.sta.Label[0],txt);

			set_status_trail(gad,txt);		
		}
		break;

		case	tab_status_value:
		{
			gad->data.sta.value = vl;

			set_status_value(gad,vl);
		}
		break;

		case	tab_status_barheight:
		{
			gad->data.sta.barheight = vl;

			set_status_barheight(gad,vl);
		}
		break;

		case	tab_status_max:
		{
			gad->data.sta.maxvalue = vl;

			set_status_maxvalue(gad,vl);
		}
		break;

//**************************** SCROLLER *****************

		case	tab_scroller_value:
		{
			gad->data.bscroller.pos = vl;

			set_scroller_value(gad,vl);
		}
		break;

		case	tab_scroller_min:
		{
			gad->data.bscroller.min = vl;
		}
		break;

		case	tab_scroller_max:
		{
			gad->data.bscroller.max = vl;
		}
		break;

		case	tab_scroller_minstep:
		{
			gad->data.bscroller.minstep = vl;

			set_scroller_minstep(gad,vl);
		}
		break;

		case	tab_scroller_maxstep:
		{
			gad->data.bscroller.maxstep = vl;

			set_scroller_maxstep(gad,vl);
		}
		break;

		case	tab_scroller_minrange:
		{
			gad->data.bscroller.minrange = vl;

			set_scroller_minrange(gad,vl);
		}
		break;

		case	tab_scroller_maxrange:
		{
			gad->data.bscroller.maxrange = vl;

			set_scroller_maxrange(gad,vl);
		}
		break;

//**************************** TAB *****************

		case	tab_tab_width:
		{
			gad->data.tab.tabwidth = id;

			set_tab_width(gad,id);
		}
		break;

		case	tab_tab_height:
		{
			gad->data.tab.tabheight = vl;

			set_tab_height(gad,vl);
		}
		break;

		case	tab_tab_selected:
		{
			gad->data.tab.sel = vl;

			set_tab_select(gad,vl);
		}
		break;

//**************************** MX *****************

		case	tab_mx_align:
		{
			gad->data.mx.align = id;

			set_mx_align(gad,id);
		}
		break;

		case	tab_mx_diviser:
		{
			gad->data.mx.pixdiv = vl;

			set_mx_divider(gad,vl);
		}
		break;

		case	tab_mx_label:
		{
			strcpy(&gad->data.mx.Label[0],txt);

			set_mx_label(gad,txt);		
		}
		break;

//**************************** SLIDER *****************

		case	tab_slider_style:
		{
			gad->data.bslider.style = id;

			set_slider_style(gad,id);
		}
		break;

		case	tab_slider_hashtype:
		{
			gad->data.bslider.hashtype = id;

			set_slider_hashtype(gad,id);
		}
		break;

		case	tab_slider_hashcount:
		{
			gad->data.bslider.hashcount = vl;

			set_slider_hashcount(gad,vl);
		}
		break;

		case	tab_slider_value:
		{
			gad->data.bslider.pos = vl;

			set_slider_value(gad,vl);
		}
		break;

		case	tab_slider_min:
		{
			gad->data.bslider.min = vl;
		}
		break;

		case	tab_slider_max:
		{
			gad->data.bslider.max = vl;
		}
		break;

		case	tab_slider_thickness:
		{
			gad->data.bslider.thickness = vl;

			set_slider_thickness(gad,vl);
		}
		break;

		case	tab_slider_keyinc:
		{
			gad->data.bslider.keyinc = vl;

			set_slider_keyinc(gad,vl);
		}
		break;

		case	tab_slider_label:
		{
			strcpy(&gad->data.bslider.Label[0],txt);

			set_slider_label(gad,txt);		
		}
		break;

		case	tab_slider_minlabel:
		{
			strcpy(&gad->data.bslider.MinLabel[0],txt);

			set_slider_minlabel(gad,txt);		
		}
		break;

		case	tab_slider_maxlabel:
		{
			strcpy(&gad->data.bslider.MaxLabel[0],txt);

			set_slider_maxlabel(gad,txt);		
		}
		break;

//**************************** COLOR *****************

		case	tab_color_layout:
		{
			gad->data.col.layout = id;

			set_color_layout(gad,id);
		}
		break;

		case	tab_color_cellsize:
		{
			gad->data.col.cellsize = id;

			set_color_cellsize(gad,id);
		}
		break;

		case	tab_color_drawbuffered:
		{
			gad->data.col.redrawbuffer = id;
		}
		break;

//**************************** LV *****************

		case	tab_lv_multi:
		{
			gad->data.lv.multi = id;
		}
		break;

//**************************** OLV *****************

		case	tab_olv_multi:
		{
			gad->data.olv.multi = id;
		}
		break;

//**************************** TEXT *****************

		case	tab_text_align:
		{
			gad->data.txt.align = id;

			set_text_align(gad,id);
		}
		break;

		case	tab_number_align:
		{
			gad->data.num.align = id;

			set_text_align(gad,id);
		}
		break;

		case	tab_text_label:
		{
			strcpy(&gad->data.txt.Label[0],txt);

			set_text_text(gad,txt);		
		}
		break;

		case	tab_number_number:
		{
			strcpy(&gad->data.num.Label[0],txt);

			set_number_value(gad,atoi(txt));		
		}
		break;

//**************************** TEDIT *****************

		case	tab_tedit_align:
		{
			gad->data.edi.align = id;
		}
		break;

		case	tab_tedit_selectable:
		{
			gad->data.edi.selectable = id;
		}
		break;

		case	tab_tedit_editable:
		{
			gad->data.edi.editable = id;
		}
		break;

		case	tab_tedit_wordwrap:
		{
			gad->data.edi.wordwrap = id;
		}
		break;

		case	tab_tedit_setstylable:
		{
			gad->data.edi.stylable = id;
		}
		break;

		case	tab_tedit_autoident:
		{
			gad->data.edi.autoident = id;
		}
		break;

		case	tab_tedit_tabwidth:
		{
			gad->data.edi.tabwidth = vl;
		}
		break;

		case	tab_tedit_maxbytes:
		{
			gad->data.edi.maxchars = vl;
		}
		break;

//**************************** END *****************
	
		default:
		{
			BWindow::MessageReceived(msg);
		}
	}
}
Ejemplo n.º 13
0
void SDistributionCurveEditor::OnSetColor()
{
	// Only works on single key...
	if(SharedData->SelectedKeys.Num() != 1)
		return;

	// Find the EdInterface for this curve.
	FCurveEditorSelectedKey& SelKey = SharedData->SelectedKeys[0];
	FCurveEdEntry& Entry = SharedData->EdSetup->Tabs[SharedData->EdSetup->ActiveTab].Curves[SelKey.CurveIndex];
	if(!Entry.bColorCurve)
		return;

	// We only do this special case if curve has 3 sub-curves.
	FCurveEdInterface* EdInterface = UInterpCurveEdSetup::GetCurveEdInterfacePointer(Entry);
	if(EdInterface->GetNumSubCurves() != 3)
		return;

	if (SharedData->NotifyObject)
	{
		// Make a list of all curves we are going to remove keys from.
		TArray<UObject*> CurvesAboutToChange;
		if(Entry.CurveObject)
		{
			CurvesAboutToChange.AddUnique(Entry.CurveObject);
			// Notify a containing tool that keys are about to be removed
			SharedData->NotifyObject->PreEditCurve(CurvesAboutToChange);
		}
	}

	// Get current value of curve as a colour.
	FColor InputColor;
	if (Entry.bFloatingPointColorCurve)
	{
		float Value;

		Value	= EdInterface->GetKeyOut(0, SelKey.KeyIndex) * 255.9f;
		InputColor.R = FMath::TruncToInt(Value);
		Value	= EdInterface->GetKeyOut(1, SelKey.KeyIndex) * 255.9f;
		InputColor.G = FMath::TruncToInt(Value);
		Value	= EdInterface->GetKeyOut(2, SelKey.KeyIndex) * 255.9f;
		InputColor.B = FMath::TruncToInt(Value);
	}
	else
	{
		InputColor.R = FMath::TruncToInt(FMath::Clamp<float>(EdInterface->GetKeyOut(0, SelKey.KeyIndex), 0.f, 255.9f));
		InputColor.G = FMath::TruncToInt(FMath::Clamp<float>(EdInterface->GetKeyOut(1, SelKey.KeyIndex), 0.f, 255.9f));
		InputColor.B = FMath::TruncToInt(FMath::Clamp<float>(EdInterface->GetKeyOut(2, SelKey.KeyIndex), 0.f, 255.9f));
	}

	//since the data isn't stored in standard colors, a temp color is used
	FColor TempColor = InputColor;

	TArray<FColor*> FColorArray;
	FColorArray.Add(&TempColor);

	FColorPickerArgs PickerArgs;
	PickerArgs.bIsModal = true;
	PickerArgs.ColorArray = &FColorArray;
	PickerArgs.DisplayGamma = TAttribute<float>::Create( TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma) );

	if (OpenColorPicker(PickerArgs))
	{
		float Value;
		if (Entry.bFloatingPointColorCurve)
		{
			Value	= (float)TempColor.R / 255.9f;
			if (Entry.bClamp)
			{
				Value = FMath::Clamp<float>(Value, Entry.ClampLow, Entry.ClampHigh);
			}
			EdInterface->SetKeyOut(0, SelKey.KeyIndex, Value);
			Value	= (float)TempColor.G / 255.9f;
			if (Entry.bClamp)
			{
				Value = FMath::Clamp<float>(Value, Entry.ClampLow, Entry.ClampHigh);
			}
			EdInterface->SetKeyOut(1, SelKey.KeyIndex, Value);
			Value	= (float)TempColor.B / 255.9f;
			if (Entry.bClamp)
			{
				Value = FMath::Clamp<float>(Value, Entry.ClampLow, Entry.ClampHigh);
			}
			EdInterface->SetKeyOut(2, SelKey.KeyIndex, Value);
		}
		else
		{
			Value = (float)(TempColor.R);
			if (Entry.bClamp)
			{
				Value = FMath::Clamp<float>(Value, Entry.ClampLow, Entry.ClampHigh);
			}
			EdInterface->SetKeyOut(0, SelKey.KeyIndex, Value);
			Value = (float)(TempColor.G);
			if (Entry.bClamp)
			{
				Value = FMath::Clamp<float>(Value, Entry.ClampLow, Entry.ClampHigh);
			}
			EdInterface->SetKeyOut(1, SelKey.KeyIndex, Value);
			Value = (float)(TempColor.B);
			if (Entry.bClamp)
			{
				Value = FMath::Clamp<float>(Value, Entry.ClampLow, Entry.ClampHigh);
			}
			EdInterface->SetKeyOut(2, SelKey.KeyIndex, Value);
		}
	}

	if (SharedData->NotifyObject)
	{
		SharedData->NotifyObject->PostEditCurve();
	}

	Viewport->RefreshViewport();
}