Skip to content

Commit bbffc95

Browse files
committed
Tweak interaction
Reset button an system visibility.
1 parent 9f3a3e3 commit bbffc95

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

newIDE/app/src/BehaviorsEditor/Editors/AnchorGrid.js

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import VerticalFillIcon from '../../UI/CustomSvgIcons/VerticalSize';
1313
import VerticalProportionalFillIcon from '../../UI/CustomSvgIcons/VerticalSizePercent';
1414
import LetterV from '../../UI/CustomSvgIcons/LetterV';
1515
import LetterH from '../../UI/CustomSvgIcons/LetterH';
16+
import Restore from '../../UI/CustomSvgIcons/Restore';
1617
import CompactTextField from '../../UI/CompactTextField';
1718
import CompactToggleButtons, {
1819
type CompactToggleButton,
@@ -37,17 +38,18 @@ const getAnchorDisplayText = (
3738
basicAnchor: BasicAnchor,
3839
axis: 'horizontal' | 'vertical'
3940
): string => {
41+
const axisLabel = axis === 'horizontal' ? 'horizontally' : 'vertically';
4042
switch (basicAnchor) {
4143
case 'MinEdge':
42-
return axis === 'horizontal' ? 'Left' : 'Bottom';
44+
return axis === 'horizontal' ? 'Left horizontally' : 'Bottom vertically';
4345
case 'Center':
44-
return 'Center';
46+
return `Center ${axisLabel}`;
4547
case 'MaxEdge':
46-
return axis === 'horizontal' ? 'Right' : 'Top';
48+
return axis === 'horizontal' ? 'Right horizontally' : 'Top vertically';
4749
case 'FixedFill':
48-
return 'Fill';
50+
return `Fill ${axisLabel}`;
4951
case 'ProportionalFill':
50-
return 'Proportional';
52+
return `Proportional ${axisLabel}`;
5153
case 'Advanced':
5254
return 'Advanced';
5355
default:
@@ -75,11 +77,11 @@ const makeButtons = (
7577
isActive: currentBasicAnchor === target,
7678
onClick: () => {
7779
if (currentBasicAnchor === target) {
78-
if (noneEntry) {
79-
onUpdateProperty(minEdgeProperty, noneEntry.minEdge);
80-
onUpdateProperty(maxEdgeProperty, noneEntry.maxEdge);
81-
}
82-
} else if (entry) {
80+
// Already active: do nothing. User must use the Restore
81+
// button in the text field to reset to None.
82+
return;
83+
}
84+
if (entry) {
8385
onUpdateProperty(minEdgeProperty, entry.minEdge);
8486
onUpdateProperty(maxEdgeProperty, entry.maxEdge);
8587
}
@@ -257,11 +259,15 @@ const AnchorGrid = ({
257259
<CompactTextField
258260
value={vDisplayValue}
259261
onChange={() => {}}
260-
disabled={!vIsNone}
261262
placeholder={vPlaceholder}
262263
renderLeftIcon={className => <LetterV className={className} />}
263264
leftIconTooltip={<Trans>Vertical</Trans>}
264-
onFocus={
265+
renderEndAdornmentOnHover={
266+
!vIsNone
267+
? className => <Restore className={className} />
268+
: undefined
269+
}
270+
onClickEndAdornment={
265271
!vIsNone
266272
? () =>
267273
clearAnchor(
@@ -292,11 +298,15 @@ const AnchorGrid = ({
292298
<CompactTextField
293299
value={hDisplayValue}
294300
onChange={() => {}}
295-
disabled={!hIsNone}
296301
placeholder={hPlaceholder}
297302
renderLeftIcon={className => <LetterH className={className} />}
298303
leftIconTooltip={<Trans>Horizontal</Trans>}
299-
onFocus={
304+
renderEndAdornmentOnHover={
305+
!hIsNone
306+
? className => <Restore className={className} />
307+
: undefined
308+
}
309+
onClickEndAdornment={
300310
!hIsNone
301311
? () =>
302312
clearAnchor(

newIDE/app/src/stories/componentStories/ObjectEditor/CompactAnchorBehaviorEditor.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const Default = (): React.Node => {
3535
object={spriteObjectWithBehaviors}
3636
behaviorMetadata={behaviorMetadata}
3737
behaviorOverriding={null}
38-
initialInstance={null}
38+
initialInstance={testProject.testLayoutInstance1}
3939
onOpenFullEditor={action('onOpenFullEditor')}
4040
onBehaviorUpdated={action('onBehaviorUpdated')}
4141
resourceManagementProps={fakeResourceManagementProps}

0 commit comments

Comments
 (0)