|
@@ -35,9 +35,11 @@ export const useActionStore = defineStore('action', () => {
|
|
|
*/
|
|
*/
|
|
|
const onAlign = (type: AlignType) => {
|
|
const onAlign = (type: AlignType) => {
|
|
|
const widgets = projectStore.activeWidgets
|
|
const widgets = projectStore.activeWidgets
|
|
|
|
|
+ const screen = projectStore.activeScreen
|
|
|
switch (type) {
|
|
switch (type) {
|
|
|
case 'left': {
|
|
case 'left': {
|
|
|
- const minX = Math.min(...widgets.map((widget) => widget.props.x))
|
|
|
|
|
|
|
+ let minX = Math.min(...widgets.map((widget) => widget.props.x))
|
|
|
|
|
+ if (widgets.length === 1) minX = 0
|
|
|
widgets.forEach((widget) => {
|
|
widgets.forEach((widget) => {
|
|
|
widget.props.x = minX
|
|
widget.props.x = minX
|
|
|
})
|
|
})
|
|
@@ -45,7 +47,8 @@ export const useActionStore = defineStore('action', () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
case 'right': {
|
|
case 'right': {
|
|
|
- const maxX = Math.max(...widgets.map((widget) => widget.props.x + widget.props.width))
|
|
|
|
|
|
|
+ let maxX = Math.max(...widgets.map((widget) => widget.props.x + widget.props.width))
|
|
|
|
|
+ if (widgets.length === 1) maxX = screen?.width ?? maxX
|
|
|
widgets.forEach((widget) => {
|
|
widgets.forEach((widget) => {
|
|
|
widget.props.x = maxX - widget.props.width
|
|
widget.props.x = maxX - widget.props.width
|
|
|
})
|
|
})
|
|
@@ -53,7 +56,8 @@ export const useActionStore = defineStore('action', () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
case 'top': {
|
|
case 'top': {
|
|
|
- const minY = Math.min(...widgets.map((widget) => widget.props.y))
|
|
|
|
|
|
|
+ let minY = Math.min(...widgets.map((widget) => widget.props.y))
|
|
|
|
|
+ if (widgets.length === 1) minY = 0
|
|
|
widgets.forEach((widget) => {
|
|
widgets.forEach((widget) => {
|
|
|
widget.props.y = minY
|
|
widget.props.y = minY
|
|
|
})
|
|
})
|
|
@@ -61,7 +65,8 @@ export const useActionStore = defineStore('action', () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
case 'bottom': {
|
|
case 'bottom': {
|
|
|
- const maxY = Math.max(...widgets.map((widget) => widget.props.y + widget.props.height))
|
|
|
|
|
|
|
+ let maxY = Math.max(...widgets.map((widget) => widget.props.y + widget.props.height))
|
|
|
|
|
+ if (widgets.length === 1) maxY = screen?.height ?? maxY
|
|
|
widgets.forEach((widget) => {
|
|
widgets.forEach((widget) => {
|
|
|
widget.props.y = maxY - widget.props.height
|
|
widget.props.y = maxY - widget.props.height
|
|
|
})
|
|
})
|
|
@@ -71,7 +76,8 @@ export const useActionStore = defineStore('action', () => {
|
|
|
case 'vcenter': {
|
|
case 'vcenter': {
|
|
|
const maxY = Math.max(...widgets.map((widget) => widget.props.y + widget.props.height))
|
|
const maxY = Math.max(...widgets.map((widget) => widget.props.y + widget.props.height))
|
|
|
const minY = Math.min(...widgets.map((widget) => widget.props.y))
|
|
const minY = Math.min(...widgets.map((widget) => widget.props.y))
|
|
|
- const centerY = minY + (maxY + minY) / 2
|
|
|
|
|
|
|
+ let centerY = minY + (maxY - minY) / 2
|
|
|
|
|
+ if (widgets.length === 1) centerY = screen?.height ? screen.height / 2 : centerY
|
|
|
widgets.forEach((widget) => {
|
|
widgets.forEach((widget) => {
|
|
|
widget.props.y = centerY - widget.props.height / 2
|
|
widget.props.y = centerY - widget.props.height / 2
|
|
|
})
|
|
})
|
|
@@ -81,7 +87,8 @@ export const useActionStore = defineStore('action', () => {
|
|
|
case 'hcenter': {
|
|
case 'hcenter': {
|
|
|
const maxX = Math.max(...widgets.map((widget) => widget.props.x + widget.props.width))
|
|
const maxX = Math.max(...widgets.map((widget) => widget.props.x + widget.props.width))
|
|
|
const minX = Math.min(...widgets.map((widget) => widget.props.x))
|
|
const minX = Math.min(...widgets.map((widget) => widget.props.x))
|
|
|
- const centerX = minX + (maxX + minX) / 2
|
|
|
|
|
|
|
+ let centerX = minX + (maxX - minX) / 2
|
|
|
|
|
+ if (widgets.length === 1) centerX = screen?.width ? screen.width / 2 : centerX
|
|
|
widgets.forEach((widget) => {
|
|
widgets.forEach((widget) => {
|
|
|
widget.props.x = centerX - widget.props.width / 2
|
|
widget.props.x = centerX - widget.props.width / 2
|
|
|
})
|
|
})
|