Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: HBox and VBox dimensions (master) #1769

Merged
merged 1 commit into from Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

This file was deleted.

24 changes: 11 additions & 13 deletions frontend-html/src/gui/Components/ScreenElements/HBox.tsx
Expand Up @@ -18,28 +18,26 @@ along with ORIGAM. If not, see <http://www.gnu.org/licenses/>.
*/

import React from "react";
import S from './HBox.module.scss';
import cx from 'classnames';
import S from './HBoxVBox.module.scss';

export class HBox extends React.Component<{
width?: number
width?: number;
height?: number;
}> {
getHBoxStyle() {
// TODO: Change to width?
if (this.props.width !== undefined) {
return {
flexShrink: 0,
width: this.props.width
};
} else {
return {
flexGrow: 1
};
return {
width: this.props.width,
height: this.props.height
}
}

render() {
return (
<div className={S.hBox} style={this.getHBoxStyle()}>
<div className={cx(S.hBox, {
[S.noWidth]: !this.props.width,
[S.noHeight]: !this.props.height
})} style={this.getHBoxStyle()}>
{this.props.children}
</div>
);
Expand Down
Expand Up @@ -17,9 +17,32 @@ You should have received a copy of the GNU General Public License
along with ORIGAM. If not, see <http://www.gnu.org/licenses/>.
*/

.hBox {
flex-shrink: 0;

width: 100%;
height: 100%;
display: flex;
flex-direction: row;

& > .hBox, & > .vBox {
&.noWidth {
flex-grow: 1;
}
}
}

.vBox {
flex-shrink: 0;

width: 100%;
height: 100%;
display: flex;
flex-direction: column;

& > .hBox, & > .vBox {
&.noHeight {
flex-grow: 1;
}
}
}
23 changes: 11 additions & 12 deletions frontend-html/src/gui/Components/ScreenElements/VBox.tsx
Expand Up @@ -18,27 +18,26 @@ along with ORIGAM. If not, see <http://www.gnu.org/licenses/>.
*/

import React from "react";
import S from './VBox.module.scss';
import cx from 'classnames';
import S from './HBoxVBox.module.scss';

export class VBox extends React.Component<{
height?: number
width?: number;
height?: number;
}> {
getVBoxStyle() {
if (this.props.height !== undefined) {
return {
flexShrink: 0,
height: this.props.height
};
} else {
return {
flexGrow: 1
};
return {
width: this.props.width,
height: this.props.height
}
}

render() {
return (
<div className={S.vBox} style={this.getVBoxStyle()}>
<div className={cx(S.vBox, {
[S.noWidth]: !this.props.width,
[S.noHeight]: !this.props.height
})} style={this.getVBoxStyle()}>
{this.props.children}
</div>
);
Expand Down
Expand Up @@ -132,6 +132,7 @@ export function desktopRecursiveBuilder(formScreen: IFormScreen, xso: any) {
return (
<VBox
key={xso.$iid}
width={xso.attributes.Width ? parseInt(xso.attributes.Width, 10) : undefined}
height={xso.attributes.Height ? parseInt(xso.attributes.Height, 10) : undefined}
>
{findUIChildren(xso).map((child) => run(child))}
Expand All @@ -142,6 +143,7 @@ export function desktopRecursiveBuilder(formScreen: IFormScreen, xso: any) {
<HBox
key={xso.$iid}
width={xso.attributes.Width ? parseInt(xso.attributes.Width, 10) : undefined}
height={xso.attributes.Height ? parseInt(xso.attributes.Height, 10) : undefined}
>
{findUIChildren(xso).map((child) => run(child))}
</HBox>
Expand Down