mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-07 22:15:38 -05:00
feat: Add a 1px border to Dankbar w/edge detection
- No edge gap (spacing = 0 AND corner radius = 0): Draws 1px border only on the exposed edge (bottom for top bar, top for bottom bar, right for left bar, left for right bar) - Has edge gap (spacing > 0 OR corner radius > 0): Draws 1px border around all sides
This commit is contained in:
@@ -150,6 +150,7 @@ Singleton {
|
|||||||
property bool dankBarSquareCorners: false
|
property bool dankBarSquareCorners: false
|
||||||
property bool dankBarNoBackground: false
|
property bool dankBarNoBackground: false
|
||||||
property bool dankBarGothCornersEnabled: false
|
property bool dankBarGothCornersEnabled: false
|
||||||
|
property bool dankBarBorderEnabled: false
|
||||||
property int dankBarPosition: SettingsData.Position.Top
|
property int dankBarPosition: SettingsData.Position.Top
|
||||||
property bool dankBarIsVertical: dankBarPosition === SettingsData.Position.Left || dankBarPosition === SettingsData.Position.Right
|
property bool dankBarIsVertical: dankBarPosition === SettingsData.Position.Left || dankBarPosition === SettingsData.Position.Right
|
||||||
property bool lockScreenShowPowerActions: true
|
property bool lockScreenShowPowerActions: true
|
||||||
@@ -359,6 +360,7 @@ Singleton {
|
|||||||
dankBarSquareCorners = settings.dankBarSquareCorners !== undefined ? settings.dankBarSquareCorners : (settings.topBarSquareCorners !== undefined ? settings.topBarSquareCorners : false)
|
dankBarSquareCorners = settings.dankBarSquareCorners !== undefined ? settings.dankBarSquareCorners : (settings.topBarSquareCorners !== undefined ? settings.topBarSquareCorners : false)
|
||||||
dankBarNoBackground = settings.dankBarNoBackground !== undefined ? settings.dankBarNoBackground : (settings.topBarNoBackground !== undefined ? settings.topBarNoBackground : false)
|
dankBarNoBackground = settings.dankBarNoBackground !== undefined ? settings.dankBarNoBackground : (settings.topBarNoBackground !== undefined ? settings.topBarNoBackground : false)
|
||||||
dankBarGothCornersEnabled = settings.dankBarGothCornersEnabled !== undefined ? settings.dankBarGothCornersEnabled : (settings.topBarGothCornersEnabled !== undefined ? settings.topBarGothCornersEnabled : false)
|
dankBarGothCornersEnabled = settings.dankBarGothCornersEnabled !== undefined ? settings.dankBarGothCornersEnabled : (settings.topBarGothCornersEnabled !== undefined ? settings.topBarGothCornersEnabled : false)
|
||||||
|
dankBarBorderEnabled = settings.dankBarBorderEnabled !== undefined ? settings.dankBarBorderEnabled : false
|
||||||
dankBarPosition = settings.dankBarPosition !== undefined ? settings.dankBarPosition : (settings.dankBarAtBottom !== undefined ? (settings.dankBarAtBottom ? SettingsData.Position.Bottom : SettingsData.Position.Top) : (settings.topBarAtBottom !== undefined ? (settings.topBarAtBottom ? SettingsData.Position.Bottom : SettingsData.Position.Top) : SettingsData.Position.Top))
|
dankBarPosition = settings.dankBarPosition !== undefined ? settings.dankBarPosition : (settings.dankBarAtBottom !== undefined ? (settings.dankBarAtBottom ? SettingsData.Position.Bottom : SettingsData.Position.Top) : (settings.topBarAtBottom !== undefined ? (settings.topBarAtBottom ? SettingsData.Position.Bottom : SettingsData.Position.Top) : SettingsData.Position.Top))
|
||||||
lockScreenShowPowerActions = settings.lockScreenShowPowerActions !== undefined ? settings.lockScreenShowPowerActions : true
|
lockScreenShowPowerActions = settings.lockScreenShowPowerActions !== undefined ? settings.lockScreenShowPowerActions : true
|
||||||
hideBrightnessSlider = settings.hideBrightnessSlider !== undefined ? settings.hideBrightnessSlider : false
|
hideBrightnessSlider = settings.hideBrightnessSlider !== undefined ? settings.hideBrightnessSlider : false
|
||||||
@@ -476,6 +478,7 @@ Singleton {
|
|||||||
"dankBarSquareCorners": dankBarSquareCorners,
|
"dankBarSquareCorners": dankBarSquareCorners,
|
||||||
"dankBarNoBackground": dankBarNoBackground,
|
"dankBarNoBackground": dankBarNoBackground,
|
||||||
"dankBarGothCornersEnabled": dankBarGothCornersEnabled,
|
"dankBarGothCornersEnabled": dankBarGothCornersEnabled,
|
||||||
|
"dankBarBorderEnabled": dankBarBorderEnabled,
|
||||||
"dankBarPosition": dankBarPosition,
|
"dankBarPosition": dankBarPosition,
|
||||||
"lockScreenShowPowerActions": lockScreenShowPowerActions,
|
"lockScreenShowPowerActions": lockScreenShowPowerActions,
|
||||||
"hideBrightnessSlider": hideBrightnessSlider,
|
"hideBrightnessSlider": hideBrightnessSlider,
|
||||||
@@ -1166,6 +1169,11 @@ Singleton {
|
|||||||
saveSettings()
|
saveSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setDankBarBorderEnabled(enabled) {
|
||||||
|
dankBarBorderEnabled = enabled
|
||||||
|
saveSettings()
|
||||||
|
}
|
||||||
|
|
||||||
function setDankBarPosition(position) {
|
function setDankBarPosition(position) {
|
||||||
dankBarPosition = position
|
dankBarPosition = position
|
||||||
if (position === SettingsData.Position.Bottom && dockPosition === SettingsData.Position.Bottom && showDock) {
|
if (position === SettingsData.Position.Bottom && dockPosition === SettingsData.Position.Bottom && showDock) {
|
||||||
|
|||||||
@@ -207,4 +207,121 @@ Item {
|
|||||||
ctx.fill()
|
ctx.fill()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Canvas {
|
||||||
|
id: barBorder
|
||||||
|
anchors.fill: parent
|
||||||
|
antialiasing: true
|
||||||
|
visible: SettingsData.dankBarBorderEnabled
|
||||||
|
renderTarget: Canvas.FramebufferObject
|
||||||
|
renderStrategy: Canvas.Cooperative
|
||||||
|
|
||||||
|
readonly property real correctWidth: root.width
|
||||||
|
readonly property real correctHeight: root.height
|
||||||
|
canvasSize: Qt.size(barWindow.px(correctWidth), barWindow.px(correctHeight))
|
||||||
|
|
||||||
|
property real wing: SettingsData.dankBarGothCornersEnabled ? barWindow._wingR : 0
|
||||||
|
property real rt: SettingsData.dankBarSquareCorners ? 0 : Theme.cornerRadius
|
||||||
|
property bool borderEnabled: SettingsData.dankBarBorderEnabled
|
||||||
|
|
||||||
|
onWingChanged: requestPaint()
|
||||||
|
onRtChanged: requestPaint()
|
||||||
|
onBorderEnabledChanged: requestPaint()
|
||||||
|
onCorrectWidthChanged: requestPaint()
|
||||||
|
onCorrectHeightChanged: requestPaint()
|
||||||
|
onVisibleChanged: if (visible) requestPaint()
|
||||||
|
Component.onCompleted: requestPaint()
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: barWindow
|
||||||
|
function on_DprChanged() { barBorder.requestPaint() }
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Theme
|
||||||
|
function onSecondaryChanged() { barBorder.requestPaint() }
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: SettingsData
|
||||||
|
function onDankBarSpacingChanged() { barBorder.requestPaint() }
|
||||||
|
function onDankBarSquareCornersChanged() { barBorder.requestPaint() }
|
||||||
|
function onCornerRadiusChanged() { barBorder.requestPaint() }
|
||||||
|
}
|
||||||
|
|
||||||
|
onPaint: {
|
||||||
|
if (!borderEnabled) return
|
||||||
|
|
||||||
|
const ctx = getContext("2d")
|
||||||
|
const scale = barWindow._dpr
|
||||||
|
const W = barWindow.px(barWindow.isVertical ? correctHeight : correctWidth)
|
||||||
|
const H_raw = barWindow.px(barWindow.isVertical ? correctWidth : correctHeight)
|
||||||
|
const R = barWindow.px(wing)
|
||||||
|
const RT = barWindow.px(rt)
|
||||||
|
const H = H_raw - (R > 0 ? R : 0)
|
||||||
|
const isTop = SettingsData.dankBarPosition === SettingsData.Position.Top
|
||||||
|
const isBottom = SettingsData.dankBarPosition === SettingsData.Position.Bottom
|
||||||
|
const isLeft = SettingsData.dankBarPosition === SettingsData.Position.Left
|
||||||
|
const isRight = SettingsData.dankBarPosition === SettingsData.Position.Right
|
||||||
|
|
||||||
|
const spacing = SettingsData.dankBarSpacing
|
||||||
|
const hasEdgeGap = spacing > 0 || RT > 0
|
||||||
|
|
||||||
|
ctx.scale(scale, scale)
|
||||||
|
|
||||||
|
function drawTopBorder() {
|
||||||
|
ctx.beginPath()
|
||||||
|
|
||||||
|
if (!hasEdgeGap) {
|
||||||
|
ctx.moveTo(0, H)
|
||||||
|
ctx.lineTo(W, H)
|
||||||
|
} else {
|
||||||
|
ctx.moveTo(RT, 0)
|
||||||
|
ctx.lineTo(W - RT, 0)
|
||||||
|
ctx.arcTo(W, 0, W, RT, RT)
|
||||||
|
ctx.lineTo(W, H)
|
||||||
|
|
||||||
|
if (R > 0) {
|
||||||
|
ctx.lineTo(W, H + R)
|
||||||
|
ctx.arc(W - R, H + R, R, 0, -Math.PI / 2, true)
|
||||||
|
ctx.lineTo(R, H)
|
||||||
|
ctx.arc(R, H + R, R, -Math.PI / 2, -Math.PI, true)
|
||||||
|
ctx.lineTo(0, H + R)
|
||||||
|
} else {
|
||||||
|
ctx.lineTo(W, H - RT)
|
||||||
|
ctx.arcTo(W, H, W - RT, H, RT)
|
||||||
|
ctx.lineTo(RT, H)
|
||||||
|
ctx.arcTo(0, H, 0, H - RT, RT)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.lineTo(0, RT)
|
||||||
|
ctx.arcTo(0, 0, RT, 0, RT)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.closePath()
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.reset()
|
||||||
|
ctx.clearRect(0, 0, W, H_raw)
|
||||||
|
|
||||||
|
ctx.save()
|
||||||
|
if (isBottom) {
|
||||||
|
ctx.translate(W, H_raw)
|
||||||
|
ctx.rotate(Math.PI)
|
||||||
|
} else if (isLeft) {
|
||||||
|
ctx.translate(0, W)
|
||||||
|
ctx.rotate(-Math.PI / 2)
|
||||||
|
} else if (isRight) {
|
||||||
|
ctx.translate(H_raw, 0)
|
||||||
|
ctx.rotate(Math.PI / 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
drawTopBorder()
|
||||||
|
ctx.restore()
|
||||||
|
|
||||||
|
ctx.lineWidth = 1
|
||||||
|
ctx.strokeStyle = Theme.secondary
|
||||||
|
ctx.stroke()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1003,6 +1003,16 @@ Item {
|
|||||||
checked)
|
checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DankToggle {
|
||||||
|
width: parent.width
|
||||||
|
text: "Border"
|
||||||
|
description: "Add a 1px border to the bar. Smart edge detection only shows border on exposed sides."
|
||||||
|
checked: SettingsData.dankBarBorderEnabled
|
||||||
|
onToggled: checked => {
|
||||||
|
SettingsData.setDankBarBorderEnabled(checked)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user