Skip to content

Commit

Permalink
Add possibility to paint tilemap with a rectangle selection from the …
Browse files Browse the repository at this point in the history
…tileset (#6977)
  • Loading branch information
AlexandreSi authored Sep 23, 2024
1 parent cc37127 commit 1fa3f59
Show file tree
Hide file tree
Showing 9 changed files with 1,208 additions and 465 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import IconButton from '../../UI/IconButton';
import { Line, Column, Spacer, marginsSize } from '../../UI/Grid';
import Text from '../../UI/Text';
import { type UnsavedChanges } from '../../MainFrame/UnsavedChangesContext';
import ScrollView from '../../UI/ScrollView';
import ScrollView, { type ScrollViewInterface } from '../../UI/ScrollView';
import EventsRootVariablesFinder from '../../Utils/EventsRootVariablesFinder';
import VariablesList, {
type HistoryHandler,
Expand Down Expand Up @@ -95,7 +95,7 @@ const CompactInstancePropertiesEditor = ({
onSelectTileMapTile,
}: Props) => {
const forceUpdate = useForceUpdate();

const scrollViewRef = React.useRef<?ScrollViewInterface>(null);
const instance = instances[0];
/**
* TODO: multiple instances support for variables list. Expected behavior should be:
Expand All @@ -105,6 +105,12 @@ const CompactInstancePropertiesEditor = ({
*/
const shouldDisplayVariablesList = instances.length === 1;

const onScrollY = React.useCallback(deltaY => {
if (scrollViewRef.current) {
scrollViewRef.current.scrollBy(deltaY);
}
}, []);

const { object, instanceSchema } = React.useMemo<{|
object?: gdObject,
instanceSchema?: Schema,
Expand Down Expand Up @@ -220,6 +226,7 @@ const CompactInstancePropertiesEditor = ({
scope="scene-editor-instance-properties"
>
<ScrollView
ref={scrollViewRef}
autoHideScrollbar
style={styles.scrollView}
key={instances
Expand Down Expand Up @@ -253,6 +260,8 @@ const CompactInstancePropertiesEditor = ({
onSelectTileMapTile={onSelectTileMapTile}
showPaintingToolbar
allowMultipleSelection={false}
onScrollY={onScrollY}
allowRectangleSelection
interactive
/>
</Column>
Expand Down
Loading

0 comments on commit 1fa3f59

Please sign in to comment.