diff options
| author | Nippy <nippy@rp1.hu> | 2026-05-08 19:50:49 +0200 |
|---|---|---|
| committer | Nippy <nippy@rp1.hu> | 2026-05-08 19:50:49 +0200 |
| commit | 3462bcc46ecf74f576ea4397f16492c16bd75b10 (patch) | |
| tree | c5ab7aef4498647e057bda8d49c11e5f9dda74c9 /raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/utils/layout.js | |
| parent | 56616f693b4f263cbf0d47da43b67424efa6022d (diff) | |
| download | RaveOS-PKGBUILD-3462bcc46ecf74f576ea4397f16492c16bd75b10.tar.gz RaveOS-PKGBUILD-3462bcc46ecf74f576ea4397f16492c16bd75b10.zip | |
raveos update
Diffstat (limited to 'raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/utils/layout.js')
| -rw-r--r-- | raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/utils/layout.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/utils/layout.js b/raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/utils/layout.js new file mode 100644 index 0000000..b8e5651 --- /dev/null +++ b/raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/utils/layout.js @@ -0,0 +1,45 @@ +function calculateRowsAndWidgets(controlCenterColumn, expandedSection, expandedWidgetIndex) { + var rows = [] + var currentRow = [] + var currentWidth = 0 + var expandedRow = -1 + + const widgets = SettingsData.controlCenterWidgets || [] + const baseWidth = controlCenterColumn.width + const spacing = Theme.spacingS + + for (var i = 0; i < widgets.length; i++) { + const widget = widgets[i] + const widgetWidth = widget.width || 50 + + var itemWidth + if (widgetWidth <= 25) { + itemWidth = (baseWidth - spacing * 3) / 4 + } else if (widgetWidth <= 50) { + itemWidth = (baseWidth - spacing) / 2 + } else if (widgetWidth <= 75) { + itemWidth = (baseWidth - spacing * 2) * 0.75 + } else { + itemWidth = baseWidth + } + + if (currentRow.length > 0 && (currentWidth + spacing + itemWidth > baseWidth)) { + rows.push([...currentRow]) + currentRow = [widget] + currentWidth = itemWidth + } else { + currentRow.push(widget) + currentWidth += (currentRow.length > 1 ? spacing : 0) + itemWidth + } + + if (expandedWidgetIndex === i) { + expandedRow = rows.length + } + } + + if (currentRow.length > 0) { + rows.push(currentRow) + } + + return { rows: rows, expandedRowIndex: expandedRow } +} |