mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-08 23:02:05 -04:00
Implement Auto-Bar location aware shadowing
This commit is contained in:
@@ -882,7 +882,8 @@ Item {
|
||||
layer.effect: MultiEffect {
|
||||
shadowEnabled: Theme.elevationEnabled
|
||||
shadowOpacity: Theme.elevationLevel1 && Theme.elevationLevel1.alpha !== undefined ? Theme.elevationLevel1.alpha : 0.2
|
||||
shadowVerticalOffset: Theme.elevationLevel1 && Theme.elevationLevel1.offsetY !== undefined ? Theme.elevationLevel1.offsetY : 1
|
||||
shadowHorizontalOffset: Theme.elevationOffsetX(Theme.elevationLevel1)
|
||||
shadowVerticalOffset: Theme.elevationOffsetY(Theme.elevationLevel1, 1)
|
||||
shadowBlur: Theme.elevationEnabled ? Math.max(0, Math.min(1, (Theme.elevationLevel1 && Theme.elevationLevel1.blurPx !== undefined ? Theme.elevationLevel1.blurPx : 4) / Theme.elevationBlurMax)) : 0
|
||||
blurMax: Theme.elevationBlurMax
|
||||
shadowColor: Theme.elevationShadowColor(Theme.elevationLevel1)
|
||||
|
||||
@@ -140,6 +140,8 @@ Item {
|
||||
scrollYBehavior: defaultBar.scrollYBehavior ?? "workspace",
|
||||
shadowIntensity: defaultBar.shadowIntensity ?? 0,
|
||||
shadowOpacity: defaultBar.shadowOpacity ?? 60,
|
||||
shadowDirectionMode: defaultBar.shadowDirectionMode ?? "inherit",
|
||||
shadowDirection: defaultBar.shadowDirection ?? "top",
|
||||
shadowColorMode: defaultBar.shadowColorMode ?? "default",
|
||||
shadowCustomColor: defaultBar.shadowCustomColor ?? "#000000"
|
||||
};
|
||||
@@ -1053,6 +1055,7 @@ Item {
|
||||
|
||||
readonly property bool shadowActive: (selectedBarConfig?.shadowIntensity ?? 0) > 0
|
||||
readonly property bool isCustomColor: (selectedBarConfig?.shadowColorMode ?? "default") === "custom"
|
||||
readonly property string directionSource: selectedBarConfig?.shadowDirectionMode ?? "inherit"
|
||||
|
||||
StyledText {
|
||||
width: parent.width
|
||||
@@ -1107,6 +1110,78 @@ Item {
|
||||
})
|
||||
}
|
||||
|
||||
SettingsDropdownRow {
|
||||
visible: shadowCard.shadowActive
|
||||
text: I18n.tr("Direction Source", "bar shadow direction source")
|
||||
description: I18n.tr("Choose how this bar resolves shadow direction")
|
||||
settingKey: "barShadowDirectionSource"
|
||||
options: [I18n.tr("Inherit Global (Default)", "bar shadow direction source option"), I18n.tr("Auto (Bar-aware)", "bar shadow direction source option"), I18n.tr("Manual", "bar shadow direction source option")]
|
||||
currentValue: {
|
||||
switch (shadowCard.directionSource) {
|
||||
case "autoBar":
|
||||
return I18n.tr("Auto (Bar-aware)", "bar shadow direction source option");
|
||||
case "manual":
|
||||
return I18n.tr("Manual", "bar shadow direction source option");
|
||||
default:
|
||||
return I18n.tr("Inherit Global (Default)", "bar shadow direction source option");
|
||||
}
|
||||
}
|
||||
onValueChanged: value => {
|
||||
if (value === I18n.tr("Auto (Bar-aware)", "bar shadow direction source option")) {
|
||||
SettingsData.updateBarConfig(selectedBarId, {
|
||||
shadowDirectionMode: "autoBar"
|
||||
});
|
||||
} else if (value === I18n.tr("Manual", "bar shadow direction source option")) {
|
||||
SettingsData.updateBarConfig(selectedBarId, {
|
||||
shadowDirectionMode: "manual"
|
||||
});
|
||||
} else {
|
||||
SettingsData.updateBarConfig(selectedBarId, {
|
||||
shadowDirectionMode: "inherit"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsDropdownRow {
|
||||
visible: shadowCard.shadowActive && shadowCard.directionSource === "manual"
|
||||
text: I18n.tr("Manual Direction", "bar manual shadow direction")
|
||||
description: I18n.tr("Use a fixed shadow direction for this bar")
|
||||
settingKey: "barShadowDirectionManual"
|
||||
options: [I18n.tr("Top", "shadow direction option"), I18n.tr("Top Left", "shadow direction option"), I18n.tr("Top Right", "shadow direction option"), I18n.tr("Bottom", "shadow direction option")]
|
||||
currentValue: {
|
||||
switch (selectedBarConfig?.shadowDirection) {
|
||||
case "topLeft":
|
||||
return I18n.tr("Top Left", "shadow direction option");
|
||||
case "topRight":
|
||||
return I18n.tr("Top Right", "shadow direction option");
|
||||
case "bottom":
|
||||
return I18n.tr("Bottom", "shadow direction option");
|
||||
default:
|
||||
return I18n.tr("Top", "shadow direction option");
|
||||
}
|
||||
}
|
||||
onValueChanged: value => {
|
||||
if (value === I18n.tr("Top Left", "shadow direction option")) {
|
||||
SettingsData.updateBarConfig(selectedBarId, {
|
||||
shadowDirection: "topLeft"
|
||||
});
|
||||
} else if (value === I18n.tr("Top Right", "shadow direction option")) {
|
||||
SettingsData.updateBarConfig(selectedBarId, {
|
||||
shadowDirection: "topRight"
|
||||
});
|
||||
} else if (value === I18n.tr("Bottom", "shadow direction option")) {
|
||||
SettingsData.updateBarConfig(selectedBarId, {
|
||||
shadowDirection: "bottom"
|
||||
});
|
||||
} else {
|
||||
SettingsData.updateBarConfig(selectedBarId, {
|
||||
shadowDirection: "top"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
visible: shadowCard.shadowActive
|
||||
width: parent.width
|
||||
|
||||
@@ -1680,6 +1680,43 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
SettingsDropdownRow {
|
||||
tab: "theme"
|
||||
tags: ["elevation", "shadow", "direction", "light", "advanced", "m3"]
|
||||
settingKey: "m3ElevationLightDirection"
|
||||
text: I18n.tr("Light Direction")
|
||||
description: I18n.tr("Controls shadow cast direction for elevation layers")
|
||||
options: [I18n.tr("Auto (Bar-aware)", "shadow direction option"), I18n.tr("Top (Default)", "shadow direction option"), I18n.tr("Top Left", "shadow direction option"), I18n.tr("Top Right", "shadow direction option"), I18n.tr("Bottom", "shadow direction option")]
|
||||
currentValue: {
|
||||
switch (SettingsData.m3ElevationLightDirection) {
|
||||
case "autoBar":
|
||||
return I18n.tr("Auto (Bar-aware)", "shadow direction option");
|
||||
case "topLeft":
|
||||
return I18n.tr("Top Left", "shadow direction option");
|
||||
case "topRight":
|
||||
return I18n.tr("Top Right", "shadow direction option");
|
||||
case "bottom":
|
||||
return I18n.tr("Bottom", "shadow direction option");
|
||||
default:
|
||||
return I18n.tr("Top (Default)", "shadow direction option");
|
||||
}
|
||||
}
|
||||
visible: SettingsData.m3ElevationEnabled ?? true
|
||||
onValueChanged: value => {
|
||||
if (value === I18n.tr("Auto (Bar-aware)", "shadow direction option")) {
|
||||
SettingsData.set("m3ElevationLightDirection", "autoBar");
|
||||
} else if (value === I18n.tr("Top Left", "shadow direction option")) {
|
||||
SettingsData.set("m3ElevationLightDirection", "topLeft");
|
||||
} else if (value === I18n.tr("Top Right", "shadow direction option")) {
|
||||
SettingsData.set("m3ElevationLightDirection", "topRight");
|
||||
} else if (value === I18n.tr("Bottom", "shadow direction option")) {
|
||||
SettingsData.set("m3ElevationLightDirection", "bottom");
|
||||
} else {
|
||||
SettingsData.set("m3ElevationLightDirection", "top");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
visible: (SettingsData.m3ElevationEnabled ?? true) && SettingsData.m3ElevationColorMode === "custom"
|
||||
width: parent.width
|
||||
|
||||
@@ -666,8 +666,8 @@ Item {
|
||||
layer.enabled: Theme.elevationEnabled
|
||||
layer.effect: MultiEffect {
|
||||
shadowEnabled: Theme.elevationEnabled
|
||||
shadowHorizontalOffset: 0
|
||||
shadowVerticalOffset: Theme.elevationLevel1 && Theme.elevationLevel1.offsetY !== undefined ? Theme.elevationLevel1.offsetY : 1
|
||||
shadowHorizontalOffset: Theme.elevationOffsetX(Theme.elevationLevel1)
|
||||
shadowVerticalOffset: Theme.elevationOffsetY(Theme.elevationLevel1, 1)
|
||||
shadowBlur: Theme.elevationEnabled ? Math.max(0, Math.min(1, (Theme.elevationLevel1 && Theme.elevationLevel1.blurPx !== undefined ? Theme.elevationLevel1.blurPx : 4) / Theme.elevationBlurMax)) : 0
|
||||
blurMax: Theme.elevationBlurMax
|
||||
shadowColor: Theme.elevationShadowColor(Theme.elevationLevel1)
|
||||
|
||||
Reference in New Issue
Block a user