Skip to content

Commit c629ba9

Browse files
authored
Display properties and effects of layers in the side panel when selected (#8055)
- This allows to quickly edit properties, notably effect properties. When the 3D editor is activated, the result are visible in real-time, which is useful to tweak lighting, shadows and other effects. This also work for layer 2D effects!
1 parent a25f7a2 commit c629ba9

File tree

29 files changed

+2394
-863
lines changed

29 files changed

+2394
-863
lines changed

newIDE/app/src/CompactPropertiesEditor/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export type ValueFieldCommonProperties = {|
4747
getExtraDescription?: Instance => string,
4848
hasImpactOnAllOtherFields?: boolean,
4949
canBeUnlimitedUsingMinus1?: boolean,
50-
disabled?: (instances: Array<gdInitialInstance>) => boolean,
50+
disabled?: (instances: Array<Instance>) => boolean,
5151
onEditButtonBuildMenuTemplate?: (i18n: I18nType) => Array<MenuItemTemplate>,
5252
onEditButtonClick?: () => void,
5353
getValueFromDisplayedValue?: string => string,
@@ -204,6 +204,7 @@ export type Field =
204204
removeSpacers?: boolean,
205205
title?: ?string,
206206
children: Array<Field>,
207+
isHidden?: (Array<Instance>) => boolean,
207208
|};
208209

209210
// The schema is the tree of all fields.
@@ -217,6 +218,7 @@ type Props = {|
217218
mode?: 'column' | 'row',
218219
preventWrap?: boolean,
219220
removeSpacers?: boolean,
221+
isHidden?: (Array<Instance>) => boolean,
220222

221223
// If set, render the "extra" description content from fields
222224
// (see getExtraDescription).
@@ -380,6 +382,7 @@ const CompactPropertiesEditor = ({
380382
resourceManagementProps,
381383
preventWrap,
382384
removeSpacers,
385+
isHidden,
383386
}: Props) => {
384387
const forceUpdate = useForceUpdate();
385388

@@ -871,7 +874,9 @@ const CompactPropertiesEditor = ({
871874
);
872875

873876
const renderContainer =
874-
mode === 'row'
877+
isHidden && isHidden(instances)
878+
? (fields: React.Node) => null
879+
: mode === 'row'
875880
? (fields: React.Node) =>
876881
preventWrap ? (
877882
removeSpacers ? (
@@ -1018,6 +1023,7 @@ const CompactPropertiesEditor = ({
10181023
onRefreshAllFields={onRefreshAllFields}
10191024
preventWrap={field.preventWrap}
10201025
removeSpacers={field.removeSpacers}
1026+
isHidden={field.isHidden}
10211027
/>
10221028
) : (
10231029
<div key={field.name} style={styles.container}>
@@ -1032,6 +1038,7 @@ const CompactPropertiesEditor = ({
10321038
onRefreshAllFields={onRefreshAllFields}
10331039
preventWrap={field.preventWrap}
10341040
removeSpacers={field.removeSpacers}
1041+
isHidden={field.isHidden}
10351042
/>
10361043
</div>
10371044
);

newIDE/app/src/InstancesEditor/CompactInstancePropertiesEditor/CompactInstancePropertiesSchema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ export const reorderInstanceSchemaForCustomProperties = (
695695
const contentSectionTitle: SectionTitle = {
696696
nonFieldType: 'sectionTitle',
697697
name: 'Content',
698-
title: 'Content',
698+
title: i18n._(t`Content`),
699699
getValue: undefined,
700700
};
701701
if (animationFieldIndex === -1) {

newIDE/app/src/InstancesEditor/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export type InstancesEditorPropsWithoutSizeAndScroll = {|
100100
layersContainer: gdLayersContainer,
101101
globalObjectsContainer: gdObjectsContainer | null,
102102
objectsContainer: gdObjectsContainer,
103-
selectedLayer: string,
103+
chosenLayer: string,
104104
initialInstances: gdInitialInstancesContainer,
105105
instancesEditorSettings: InstancesEditorSettings,
106106
isInstanceOf3DObject: gdInitialInstance => boolean,
@@ -1686,7 +1686,7 @@ export default class InstancesEditor extends Component<Props, State> {
16861686
_instancesAdder.createOrUpdateTemporaryInstancesFromObjectNames(
16871687
pos,
16881688
this.props.selectedObjectNames,
1689-
this.props.selectedLayer
1689+
this.props.chosenLayer
16901690
);
16911691
}}
16921692
drop={monitor => {

newIDE/app/src/LayersList/BackgroundColorRow.js

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// @flow
2+
import { type I18n as I18nType } from '@lingui/core';
3+
import { t } from '@lingui/macro';
4+
5+
import * as React from 'react';
6+
import { TreeViewItemContent } from '.';
7+
import { type HTMLDataset } from '../Utils/HTMLDataset';
8+
import ColorPicker from '../UI/ColorField/ColorPicker';
9+
10+
export const backgroundColorId = 'background-color';
11+
12+
export class BackgroundColorTreeViewItemContent implements TreeViewItemContent {
13+
layout: gdLayout;
14+
onBackgroundColorChanged: () => void;
15+
16+
constructor(layout: gdLayout, onBackgroundColorChanged: () => void) {
17+
this.layout = layout;
18+
this.onBackgroundColorChanged = onBackgroundColorChanged;
19+
}
20+
21+
getName(i18n: I18nType): string | React.Node {
22+
return i18n._(t`Background color`);
23+
}
24+
25+
getId(): string {
26+
return backgroundColorId;
27+
}
28+
29+
getRightButton(i18n: I18nType) {
30+
return [];
31+
}
32+
33+
getHtmlId(index: number): ?string {
34+
return backgroundColorId;
35+
}
36+
37+
getDataSet(): ?HTMLDataset {
38+
return null;
39+
}
40+
41+
getThumbnail(): ?string {
42+
return null;
43+
}
44+
45+
onClick(): void {}
46+
47+
buildMenuTemplate(i18n: I18nType, index: number) {
48+
return [];
49+
}
50+
51+
renderRightComponent(i18n: I18nType): ?React.Node {
52+
return (
53+
<ColorPicker
54+
disableAlpha
55+
color={{
56+
r: this.layout.getBackgroundColorRed(),
57+
g: this.layout.getBackgroundColorGreen(),
58+
b: this.layout.getBackgroundColorBlue(),
59+
a: 255,
60+
}}
61+
onChangeComplete={color => {
62+
this.layout.setBackgroundColor(color.rgb.r, color.rgb.g, color.rgb.b);
63+
this.onBackgroundColorChanged();
64+
}}
65+
/>
66+
);
67+
}
68+
69+
rename(newName: string): void {}
70+
71+
edit(): void {}
72+
73+
delete(): void {}
74+
75+
copy(): void {}
76+
77+
paste(): void {}
78+
79+
cut(): void {}
80+
81+
getIndex(): number {
82+
return 0;
83+
}
84+
85+
moveAt(destinationIndex: number): void {}
86+
87+
isDescendantOf(itemContent: TreeViewItemContent): boolean {
88+
return false;
89+
}
90+
91+
getRootId(): string {
92+
return '';
93+
}
94+
}

0 commit comments

Comments
 (0)