Add color Parameter
This commit is contained in:
parent
3b255245f2
commit
8cc8819cd3
@ -7,6 +7,8 @@ type ITemplateBehaviorParameter = {
|
|||||||
testNumber: "number";
|
testNumber: "number";
|
||||||
testString: "string";
|
testString: "string";
|
||||||
testBoolean: "boolean";
|
testBoolean: "boolean";
|
||||||
|
testColor: "color";
|
||||||
|
testOption: "option";
|
||||||
testR: "R";
|
testR: "R";
|
||||||
testG: "G";
|
testG: "G";
|
||||||
testLR: "LR";
|
testLR: "LR";
|
||||||
@ -43,6 +45,16 @@ class Template extends Behavior<ITemplateBehaviorParameter, ITemplateBehaviorEve
|
|||||||
defaultValue: "default",
|
defaultValue: "default",
|
||||||
maxLength: 12
|
maxLength: 12
|
||||||
},
|
},
|
||||||
|
testColor: {
|
||||||
|
name: "$Test",
|
||||||
|
type: "color",
|
||||||
|
defaultValue: [.5, .1, 1],
|
||||||
|
colorNormal: true
|
||||||
|
},
|
||||||
|
testOption: {
|
||||||
|
name: "$Test",
|
||||||
|
type: "option"
|
||||||
|
},
|
||||||
testBoolean: {
|
testBoolean: {
|
||||||
name: "$Test",
|
name: "$Test",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
|
@ -6,6 +6,7 @@ import { TogglesInput } from "@Input/TogglesInput/TogglesInput";
|
|||||||
import { ObjectPicker } from "@Input/ObjectPicker/ObjectPicker";
|
import { ObjectPicker } from "@Input/ObjectPicker/ObjectPicker";
|
||||||
import { AllI18nKeys } from "@Component/Localization/Localization";
|
import { AllI18nKeys } from "@Component/Localization/Localization";
|
||||||
import { Message } from "@Input/Message/Message";
|
import { Message } from "@Input/Message/Message";
|
||||||
|
import { ColorInput } from "@Input/ColorInput/ColorInput";
|
||||||
import {
|
import {
|
||||||
IParameter, IParameterOption, IParameterOptionItem,
|
IParameter, IParameterOption, IParameterOptionItem,
|
||||||
IParameterValue, IParamValue, isObjectType, isVectorType
|
IParameterValue, IParamValue, isObjectType, isVectorType
|
||||||
@ -71,6 +72,7 @@ class Parameter<P extends IParameter> extends Component<IParameterProps<P> & IMi
|
|||||||
keyI18n="Panel.Info.Behavior.Details.Parameter.Key"
|
keyI18n="Panel.Info.Behavior.Details.Parameter.Key"
|
||||||
keyI18nOption={{ key: i18nString }}
|
keyI18nOption={{ key: i18nString }}
|
||||||
onIconName={option.iconName}
|
onIconName={option.iconName}
|
||||||
|
red={option.iconRed}
|
||||||
value={value as IParamValue<"boolean"> ?? false}
|
value={value as IParamValue<"boolean"> ?? false}
|
||||||
valueChange={(val) => {
|
valueChange={(val) => {
|
||||||
this.props.change(key, val as IParamValue<P[K]>);
|
this.props.change(key, val as IParamValue<P[K]>);
|
||||||
@ -100,7 +102,21 @@ class Parameter<P extends IParameter> extends Component<IParameterProps<P> & IMi
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (isVectorType(type)) {
|
else if (type === "color") {
|
||||||
|
|
||||||
|
return <ColorInput
|
||||||
|
key={indexKey}
|
||||||
|
keyI18n="Panel.Info.Behavior.Details.Parameter.Key"
|
||||||
|
keyI18nOption={{ key: i18nString }}
|
||||||
|
normal={option.colorNormal}
|
||||||
|
value={value as IParamValue<"color"> ?? false}
|
||||||
|
valueChange={(val) => {
|
||||||
|
this.props.change(key, val as IParamValue<P[K]>);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (type === "vec") {
|
||||||
|
|
||||||
type IObjectParamValue = IParamValue<"vec">;
|
type IObjectParamValue = IParamValue<"vec">;
|
||||||
const typedValue = value as IObjectParamValue;
|
const typedValue = value as IObjectParamValue;
|
||||||
|
@ -14,6 +14,7 @@ type IMapBasicParamTypeKeyToType = {
|
|||||||
"number": number;
|
"number": number;
|
||||||
"string": string;
|
"string": string;
|
||||||
"boolean": boolean;
|
"boolean": boolean;
|
||||||
|
"option": string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type IMapObjectParamTypeKeyToType = {
|
type IMapObjectParamTypeKeyToType = {
|
||||||
@ -25,6 +26,7 @@ type IMapObjectParamTypeKeyToType = {
|
|||||||
|
|
||||||
type IMapVectorParamTypeKeyToType = {
|
type IMapVectorParamTypeKeyToType = {
|
||||||
"vec": number[];
|
"vec": number[];
|
||||||
|
"color": number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,6 +102,21 @@ interface IParameterOptionItem<T extends IParamType = IParamType> {
|
|||||||
* 图标名字
|
* 图标名字
|
||||||
*/
|
*/
|
||||||
iconName?: string;
|
iconName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图标是否显示为红色
|
||||||
|
*/
|
||||||
|
iconRed?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 颜色是否进行归一化
|
||||||
|
*/
|
||||||
|
colorNormal?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全部选项
|
||||||
|
*/
|
||||||
|
allOption?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IParameter {
|
interface IParameter {
|
||||||
|
Loading…
Reference in New Issue
Block a user