Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H committed Oct 1, 2024
1 parent 2c63a9a commit 3d8aee7
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 96 deletions.
2 changes: 1 addition & 1 deletion Extensions/TextObject/TextObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ std::map<gd::String, gd::PropertyDescriptor> TextObject::GetProperties() const {
.AddExtraInfo("top")
.AddExtraInfo("center")
.AddExtraInfo("bottom")
.SetLabel(_("Vertical alignment, when multiple lines are displayed"))
.SetLabel(_("Vertical alignment"))
.SetGroup(_("Font"));

objectProperties["isOutlineEnabled"]
Expand Down
8 changes: 4 additions & 4 deletions Extensions/TextObject/textruntimeobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ namespace gdjs {
_gradient: Array<Array<integer>> = [];
_gradientType: string = '';
opacity: float = 255;
_textAlign: string = 'left';
_verticalTextAlignment: string = 'top';
_textAlign: string;
_verticalTextAlignment: string;
_wrapping: boolean = false;
// A wrapping of 1 makes games crash on Firefox
_wrappingWidth: float = 100;
Expand Down Expand Up @@ -125,8 +125,8 @@ namespace gdjs {
this._underlined = content.underlined;
this._color = gdjs.rgbOrHexToRGBColor(content.color);
this._str = content.text;
this._textAlign = content.textAlignment;
this._verticalTextAlignment = content.verticalTextAlignment;
this._textAlign = content.textAlignment || 'left';
this._verticalTextAlignment = content.verticalTextAlignment || 'top';

this._isOutlineEnabled = content.isOutlineEnabled;
this._outlineThickness = content.outlineThickness;
Expand Down
163 changes: 72 additions & 91 deletions newIDE/app/src/ObjectEditor/Editors/TextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { type EditorProps } from './EditorProps.flow';
import SemiControlledTextField from '../../UI/SemiControlledTextField';
import ButtonGroup from '@material-ui/core/ButtonGroup';
import Button from '@material-ui/core/Button';
import Tooltip from '@material-ui/core/Tooltip';
import LeftTextAlignment from '../../UI/CustomSvgIcons/LeftTextAlignment';
import CenterTextAlignment from '../../UI/CustomSvgIcons/CenterTextAlignment';
import RightTextAlignment from '../../UI/CustomSvgIcons/RightTextAlignment';
Expand Down Expand Up @@ -123,98 +122,80 @@ export default class TextEditor extends React.Component<EditorProps, void> {
</Line>
<LineStackLayout noMargin alignItems="center">
<ButtonGroup size="small">
<Tooltip title={<Trans>Align text on the left</Trans>}>
<Button
variant={textAlignment === 'left' ? 'contained' : 'outlined'}
color={textAlignment === 'left' ? 'secondary' : 'default'}
onClick={() => {
textObjectConfiguration.setTextAlignment('left');
this.forceUpdate();
}}
>
<LeftTextAlignment />
</Button>
</Tooltip>
<Tooltip title={<Trans>Align text on the center</Trans>}>
<Button
variant={
textAlignment === 'center' ? 'contained' : 'outlined'
}
color={textAlignment === 'center' ? 'secondary' : 'default'}
onClick={() => {
textObjectConfiguration.setTextAlignment('center');
this.forceUpdate();
}}
>
<CenterTextAlignment />
</Button>
</Tooltip>
<Tooltip title={<Trans>Align text on the right</Trans>}>
<Button
variant={textAlignment === 'right' ? 'contained' : 'outlined'}
color={textAlignment === 'right' ? 'secondary' : 'default'}
onClick={() => {
textObjectConfiguration.setTextAlignment('right');
this.forceUpdate();
}}
>
<RightTextAlignment />
</Button>
</Tooltip>
<Button
variant={textAlignment === 'left' ? 'contained' : 'outlined'}
color={textAlignment === 'left' ? 'secondary' : 'default'}
onClick={() => {
textObjectConfiguration.setTextAlignment('left');
this.forceUpdate();
}}
>
<LeftTextAlignment />
</Button>
<Button
variant={textAlignment === 'center' ? 'contained' : 'outlined'}
color={textAlignment === 'center' ? 'secondary' : 'default'}
onClick={() => {
textObjectConfiguration.setTextAlignment('center');
this.forceUpdate();
}}
>
<CenterTextAlignment />
</Button>
<Button
variant={textAlignment === 'right' ? 'contained' : 'outlined'}
color={textAlignment === 'right' ? 'secondary' : 'default'}
onClick={() => {
textObjectConfiguration.setTextAlignment('right');
this.forceUpdate();
}}
>
<RightTextAlignment />
</Button>
</ButtonGroup>
<ButtonGroup size="small">
<Tooltip title={<Trans>Align text on the top</Trans>}>
<Button
variant={
verticalTextAlignment === 'top' ? 'contained' : 'outlined'
}
color={
verticalTextAlignment === 'top' ? 'secondary' : 'default'
}
onClick={() => {
textObjectConfiguration.setVerticalTextAlignment('top');
this.forceUpdate();
}}
>
<TopTextAlignment />
</Button>
</Tooltip>
<Tooltip title={<Trans>Align text on the center</Trans>}>
<Button
variant={
verticalTextAlignment === 'center'
? 'contained'
: 'outlined'
}
color={
verticalTextAlignment === 'center' ? 'secondary' : 'default'
}
onClick={() => {
textObjectConfiguration.setVerticalTextAlignment('center');
this.forceUpdate();
}}
>
<CenterVerticalTextAlignment />
</Button>
</Tooltip>
<Tooltip title={<Trans>Align text on the bottom</Trans>}>
<Button
variant={
verticalTextAlignment === 'bottom'
? 'contained'
: 'outlined'
}
color={
verticalTextAlignment === 'bottom' ? 'secondary' : 'default'
}
onClick={() => {
textObjectConfiguration.setVerticalTextAlignment('bottom');
this.forceUpdate();
}}
>
<BottomTextAlignment />
</Button>
</Tooltip>
<Button
variant={
verticalTextAlignment === 'top' ? 'contained' : 'outlined'
}
color={
verticalTextAlignment === 'top' ? 'secondary' : 'default'
}
onClick={() => {
textObjectConfiguration.setVerticalTextAlignment('top');
this.forceUpdate();
}}
>
<TopTextAlignment />
</Button>
<Button
variant={
verticalTextAlignment === 'center' ? 'contained' : 'outlined'
}
color={
verticalTextAlignment === 'center' ? 'secondary' : 'default'
}
onClick={() => {
textObjectConfiguration.setVerticalTextAlignment('center');
this.forceUpdate();
}}
>
<CenterVerticalTextAlignment />
</Button>
<Button
variant={
verticalTextAlignment === 'bottom' ? 'contained' : 'outlined'
}
color={
verticalTextAlignment === 'bottom' ? 'secondary' : 'default'
}
onClick={() => {
textObjectConfiguration.setVerticalTextAlignment('bottom');
this.forceUpdate();
}}
>
<BottomTextAlignment />
</Button>
</ButtonGroup>
</LineStackLayout>
</ResponsiveLineStackLayout>
Expand Down

0 comments on commit 3d8aee7

Please sign in to comment.