mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-13 01:02:18 -04:00
Implement Auto-Bar location aware shadowing
This commit is contained in:
@@ -56,9 +56,33 @@ Item {
|
||||
// M3 elevation shadow — Level 2 baseline (navigation bar), with per-bar override support
|
||||
readonly property bool hasPerBarOverride: (barConfig?.shadowIntensity ?? 0) > 0
|
||||
readonly property var elevLevel: Theme.elevationLevel2
|
||||
readonly property bool shadowEnabled: (Theme.elevationEnabled
|
||||
&& (typeof SettingsData !== "undefined" ? (SettingsData.barElevationEnabled ?? true) : false))
|
||||
|| hasPerBarOverride
|
||||
readonly property bool shadowEnabled: (Theme.elevationEnabled && (typeof SettingsData !== "undefined" ? (SettingsData.barElevationEnabled ?? true) : false)) || hasPerBarOverride
|
||||
readonly property string autoBarShadowDirection: isTop ? "top" : (isBottom ? "bottom" : (isLeft ? "left" : (isRight ? "right" : "top")))
|
||||
readonly property string globalShadowDirection: Theme.elevationLightDirection === "autoBar" ? autoBarShadowDirection : Theme.elevationLightDirection
|
||||
readonly property string perBarShadowDirectionMode: barConfig?.shadowDirectionMode ?? "inherit"
|
||||
readonly property string perBarManualShadowDirection: {
|
||||
switch (barConfig?.shadowDirection) {
|
||||
case "top":
|
||||
case "topLeft":
|
||||
case "topRight":
|
||||
case "bottom":
|
||||
return barConfig.shadowDirection;
|
||||
default:
|
||||
return "top";
|
||||
}
|
||||
}
|
||||
readonly property string effectiveShadowDirection: {
|
||||
if (!hasPerBarOverride)
|
||||
return globalShadowDirection;
|
||||
switch (perBarShadowDirectionMode) {
|
||||
case "autoBar":
|
||||
return autoBarShadowDirection;
|
||||
case "manual":
|
||||
return perBarManualShadowDirection === "autoBar" ? autoBarShadowDirection : perBarManualShadowDirection;
|
||||
default:
|
||||
return globalShadowDirection;
|
||||
}
|
||||
}
|
||||
|
||||
// Per-bar override values (when barConfig.shadowIntensity > 0)
|
||||
readonly property real overrideBlurPx: (barConfig?.shadowIntensity ?? 0) * 0.2
|
||||
@@ -82,12 +106,10 @@ Item {
|
||||
// Resolved values — per-bar override wins if set, otherwise use global M3 elevation
|
||||
readonly property real shadowBlurPx: hasPerBarOverride ? overrideBlurPx : (elevLevel.blurPx ?? 8)
|
||||
readonly property real shadowBlur: Math.max(0, Math.min(1, shadowBlurPx / Theme.elevationBlurMax))
|
||||
readonly property color shadowColor: hasPerBarOverride
|
||||
? Theme.withAlpha(overrideBaseColor, overrideOpacity)
|
||||
: Theme.elevationShadowColor(elevLevel)
|
||||
readonly property real shadowOffsetY: hasPerBarOverride
|
||||
? overrideBlurPx * 0.5
|
||||
: (elevLevel.offsetY ?? 4)
|
||||
readonly property color shadowColor: hasPerBarOverride ? Theme.withAlpha(overrideBaseColor, overrideOpacity) : Theme.elevationShadowColor(elevLevel)
|
||||
readonly property real shadowOffsetMagnitude: hasPerBarOverride ? (overrideBlurPx * 0.5) : Theme.elevationOffsetMagnitude(elevLevel, 4, effectiveShadowDirection)
|
||||
readonly property real shadowOffsetX: Theme.elevationOffsetXFor(hasPerBarOverride ? null : elevLevel, effectiveShadowDirection, shadowOffsetMagnitude)
|
||||
readonly property real shadowOffsetY: Theme.elevationOffsetYFor(hasPerBarOverride ? null : elevLevel, effectiveShadowDirection, shadowOffsetMagnitude)
|
||||
|
||||
readonly property string mainPath: generatePathForPosition(width, height)
|
||||
readonly property string borderFullPath: generateBorderFullPath(width, height)
|
||||
@@ -148,8 +170,8 @@ Item {
|
||||
shadowBlur: root.shadowBlur
|
||||
blurMax: Theme.elevationBlurMax
|
||||
shadowColor: root.shadowColor
|
||||
shadowVerticalOffset: root.isTop ? root.shadowOffsetY : (root.isBottom ? -root.shadowOffsetY : 0)
|
||||
shadowHorizontalOffset: root.isLeft ? root.shadowOffsetY : (root.isRight ? -root.shadowOffsetY : 0)
|
||||
shadowVerticalOffset: root.shadowOffsetY
|
||||
shadowHorizontalOffset: root.shadowOffsetX
|
||||
autoPaddingEnabled: true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user