fix(ui): hide scale method from HUD when disabled

This commit is contained in:
psychedelicious
2024-09-18 10:43:22 +10:00
committed by Kent Keirsey
parent d6da2aa3f7
commit 4f8782f616
2 changed files with 8 additions and 4 deletions

View File

@@ -1,16 +1,18 @@
import { createSelector } from '@reduxjs/toolkit';
import { useAppSelector } from 'app/store/storeHooks';
import { CanvasHUDItem } from 'features/controlLayers/components/HUD/CanvasHUDItem';
import { selectBbox } from 'features/controlLayers/store/selectors';
import { selectScaledSize, selectScaleMethod } from 'features/controlLayers/store/selectors';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
const selectScaledSize = createSelector(selectBbox, (bbox) => bbox.scaledSize);
export const CanvasHUDItemScaledBbox = memo(() => {
const { t } = useTranslation();
const scaleMethod = useAppSelector(selectScaleMethod);
const scaledSize = useAppSelector(selectScaledSize);
if (scaleMethod === 'none') {
return null;
}
return (
<CanvasHUDItem label={t('controlLayers.HUD.scaledBbox')} value={`${scaledSize.width}×${scaledSize.height} px`} />
);

View File

@@ -288,3 +288,5 @@ export const selectWidth = createSelector(selectCanvasSlice, (canvas) => canvas.
export const selectHeight = createSelector(selectCanvasSlice, (canvas) => canvas.bbox.rect.height);
export const selectAspectRatioID = createSelector(selectCanvasSlice, (canvas) => canvas.bbox.aspectRatio.id);
export const selectAspectRatioValue = createSelector(selectCanvasSlice, (canvas) => canvas.bbox.aspectRatio.value);
export const selectScaledSize = createSelector(selectBbox, (bbox) => bbox.scaledSize);
export const selectScaleMethod = createSelector(selectBbox, (bbox) => bbox.scaleMethod);