mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-05-18 11:46:18 +00:00
Make tweak columns responsive
This commit is contained in:
@@ -198,7 +198,10 @@ function Show-MainWindow {
|
||||
}
|
||||
}
|
||||
|
||||
$window.Add_SizeChanged({ & $updateContentMargin })
|
||||
$window.Add_SizeChanged({
|
||||
& $updateContentMargin
|
||||
UpdateTweaksResponsiveColumns
|
||||
})
|
||||
|
||||
$window.Add_StateChanged({
|
||||
& $updateWindowChrome
|
||||
@@ -595,6 +598,8 @@ function Show-MainWindow {
|
||||
|
||||
$script:UiControlMappings = @{}
|
||||
$script:CategoryCardMap = @{}
|
||||
$script:TweaksCompactMode = $null
|
||||
$script:TweaksCardsMovedFromCol2 = @()
|
||||
|
||||
function CreateLabeledCombo($parent, $labelText, $comboName, $items) {
|
||||
# If only 2 items (No Change + one option), use a checkbox instead
|
||||
@@ -1255,6 +1260,52 @@ function Show-MainWindow {
|
||||
$col0 = $window.FindName('Column0Panel')
|
||||
$col1 = $window.FindName('Column1Panel')
|
||||
$col2 = $window.FindName('Column2Panel')
|
||||
|
||||
function UpdateTweaksResponsiveColumns {
|
||||
if (-not $tweaksGrid -or -not $col0 -or -not $col1 -or -not $col2) { return }
|
||||
if ($tweaksGrid.ColumnDefinitions.Count -lt 3) { return }
|
||||
if ($null -eq $script:TweaksCardsMovedFromCol2) { $script:TweaksCardsMovedFromCol2 = @() }
|
||||
|
||||
$useTwoColumns = $window.ActualWidth -lt 1200
|
||||
if ($script:TweaksCompactMode -eq $useTwoColumns) { return }
|
||||
$script:TweaksCompactMode = $useTwoColumns
|
||||
|
||||
if ($useTwoColumns) {
|
||||
$tweaksGrid.ColumnDefinitions[0].Width = [System.Windows.GridLength]::new(1, [System.Windows.GridUnitType]::Star)
|
||||
$tweaksGrid.ColumnDefinitions[1].Width = [System.Windows.GridLength]::new(1, [System.Windows.GridUnitType]::Star)
|
||||
$tweaksGrid.ColumnDefinitions[2].Width = [System.Windows.GridLength]::new(0)
|
||||
$col2.Visibility = 'Collapsed'
|
||||
|
||||
# Move third-column cards once when entering compact mode.
|
||||
$cardsToMove = @($col2.Children) | Where-Object { $_ -is [System.Windows.UIElement] }
|
||||
$script:TweaksCardsMovedFromCol2 = @($cardsToMove)
|
||||
$col2.Children.Clear()
|
||||
$targetColumns = @($col0, $col1)
|
||||
foreach ($card in $cardsToMove) {
|
||||
$target = $targetColumns |
|
||||
Sort-Object @{Expression={$_.Children.Count}; Ascending=$true}, @{Expression={$targetColumns.IndexOf($_)}; Ascending=$true} |
|
||||
Select-Object -First 1
|
||||
$target.Children.Add($card) | Out-Null
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
$tweaksGrid.ColumnDefinitions[0].Width = [System.Windows.GridLength]::new(1, [System.Windows.GridUnitType]::Star)
|
||||
$tweaksGrid.ColumnDefinitions[1].Width = [System.Windows.GridLength]::new(1, [System.Windows.GridUnitType]::Star)
|
||||
$tweaksGrid.ColumnDefinitions[2].Width = [System.Windows.GridLength]::new(1, [System.Windows.GridUnitType]::Star)
|
||||
$col2.Visibility = 'Visible'
|
||||
|
||||
foreach ($card in (@($script:TweaksCardsMovedFromCol2) | Where-Object { $_ -is [System.Windows.UIElement] })) {
|
||||
if ($col0.Children.Contains($card)) {
|
||||
$col0.Children.Remove($card) | Out-Null
|
||||
}
|
||||
elseif ($col1.Children.Contains($card)) {
|
||||
$col1.Children.Remove($card) | Out-Null
|
||||
}
|
||||
$col2.Children.Add($card) | Out-Null
|
||||
}
|
||||
$script:TweaksCardsMovedFromCol2 = @()
|
||||
}
|
||||
|
||||
# Monitor scrollbar visibility and adjust searchbar margin
|
||||
$tweaksScrollViewer.Add_ScrollChanged({
|
||||
@@ -1829,6 +1880,7 @@ function Show-MainWindow {
|
||||
# Initialize UI elements on window load
|
||||
$window.Add_Loaded({
|
||||
BuildDynamicTweaks
|
||||
UpdateTweaksResponsiveColumns
|
||||
RefreshTweakPresetSources -defaultSettingsJson $defaultsJson -lastUsedSettingsJson $lastUsedSettingsJson
|
||||
RegisterTweakPresetControlStateHandlers
|
||||
UpdateTweakPresetStates
|
||||
|
||||
Reference in New Issue
Block a user