glass design
This commit is contained in:
1 parent
f67d7f1c55
commit
f370e0de56
6 files changed
+194
-48
No files matched your search
@@ -0,0 +1,100 @@
|
||||
import QtQuick
|
||||
|
||||
// A see-through glass panel: a light tint, a soft shine over the top half,
|
||||
// a rim that catches the light along the top and a shadow underneath.
|
||||
// It only draws the glass; put the content on top of it.
|
||||
Item {
|
||||
id: root
|
||||
|
||||
required property Theme theme
|
||||
required property real radius
|
||||
required property color tint
|
||||
// Blue tint and a glowing blue rim.
|
||||
required property bool selected
|
||||
// Soft shadow underneath. Off where the window is too small to hold it.
|
||||
required property bool shadow
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: root.radius
|
||||
color: root.selected ? root.theme.glassSelectedTint : root.tint
|
||||
antialiasing: true
|
||||
}
|
||||
|
||||
// Shine over the top half, like light on curved glass.
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: root.radius
|
||||
antialiasing: true
|
||||
gradient: Gradient {
|
||||
GradientStop {
|
||||
position: 0
|
||||
color: root.theme.glassShine
|
||||
}
|
||||
GradientStop {
|
||||
position: 0.55
|
||||
color: Qt.rgba(1, 1, 1, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The rim, bright at the top and fading down, and the shadow around
|
||||
// the outside. Bigger than the panel so the shadow has room.
|
||||
Canvas {
|
||||
id: edge
|
||||
|
||||
readonly property real margin: root.shadow ? root.theme.glassShadowBlur + root.theme.glassShadowOffset : 0
|
||||
readonly property color rimTop: root.selected ? root.theme.fieldBorder : root.theme.glassRimTop
|
||||
readonly property color rimBottom: root.selected ? root.theme.glassSelectedRimBottom : root.theme.glassRimBottom
|
||||
readonly property real rimWidth: root.selected ? 2 : 1
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: -edge.margin
|
||||
|
||||
onWidthChanged: edge.requestPaint()
|
||||
onHeightChanged: edge.requestPaint()
|
||||
onRimTopChanged: edge.requestPaint()
|
||||
onRimBottomChanged: edge.requestPaint()
|
||||
onRimWidthChanged: edge.requestPaint()
|
||||
|
||||
onPaint: {
|
||||
const ctx = edge.getContext("2d");
|
||||
ctx.reset();
|
||||
const m = edge.margin;
|
||||
const w = root.width;
|
||||
const h = root.height;
|
||||
const r = Math.min(root.radius, w / 2, h / 2);
|
||||
if (w <= 0 || h <= 0)
|
||||
return;
|
||||
|
||||
if (root.shadow) {
|
||||
ctx.save();
|
||||
ctx.shadowColor = root.theme.glassShadow;
|
||||
ctx.shadowBlur = root.theme.glassShadowBlur;
|
||||
ctx.shadowOffsetY = root.theme.glassShadowOffset;
|
||||
ctx.fillStyle = "black";
|
||||
ctx.beginPath();
|
||||
ctx.roundedRect(m, m, w, h, r, r);
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
// Clear the panel itself, so the shadow only shows outside
|
||||
// and the glass stays see-through.
|
||||
ctx.globalCompositeOperation = "destination-out";
|
||||
ctx.beginPath();
|
||||
ctx.roundedRect(m, m, w, h, r, r);
|
||||
ctx.fill();
|
||||
ctx.globalCompositeOperation = "source-over";
|
||||
}
|
||||
|
||||
const half = edge.rimWidth / 2;
|
||||
const rim = ctx.createLinearGradient(0, m, 0, m + h);
|
||||
rim.addColorStop(0, edge.rimTop);
|
||||
rim.addColorStop(1, edge.rimBottom);
|
||||
ctx.strokeStyle = rim;
|
||||
ctx.lineWidth = edge.rimWidth;
|
||||
ctx.beginPath();
|
||||
ctx.roundedRect(m + half, m + half, w - edge.rimWidth, h - edge.rimWidth, r - half, r - half);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import QtQuick.Effects
|
||||
|
||||
PanelWindow {
|
||||
id: root
|
||||
@@ -267,13 +266,6 @@ PanelWindow {
|
||||
anchors.fill: parent
|
||||
color: root.theme.backdrop
|
||||
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
blurEnabled: true
|
||||
blur: 1.0
|
||||
blurMax: 64
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
@@ -298,12 +290,17 @@ PanelWindow {
|
||||
height: root.theme.barHeight
|
||||
z: 10
|
||||
|
||||
Rectangle {
|
||||
Glass {
|
||||
anchors.fill: parent
|
||||
theme: root.theme
|
||||
radius: root.theme.cornerRadius
|
||||
color: root.theme.barBg
|
||||
border.color: root.theme.barBorder
|
||||
border.width: 1
|
||||
tint: root.theme.barBg
|
||||
selected: false
|
||||
shadow: true
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
@@ -331,15 +328,20 @@ PanelWindow {
|
||||
font.pixelSize: root.theme.fontSize
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Item {
|
||||
id: field
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width - label.width - okButton.width - root.theme.logoSize - root.theme.barSpacing * 3
|
||||
height: root.theme.barHeight - root.theme.barPadding * 2
|
||||
radius: root.theme.cornerRadius / 2
|
||||
color: root.theme.fieldBg
|
||||
border.color: nameInput.activeFocus ? root.theme.fieldBorder : root.theme.barBorder
|
||||
border.width: 1
|
||||
|
||||
Glass {
|
||||
anchors.fill: parent
|
||||
theme: root.theme
|
||||
radius: root.theme.cornerRadius / 2
|
||||
tint: root.theme.fieldBg
|
||||
selected: nameInput.activeFocus
|
||||
shadow: false
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: nameInput
|
||||
@@ -611,17 +613,23 @@ PanelWindow {
|
||||
}
|
||||
|
||||
// Monitor name, above the rename bar.
|
||||
Rectangle {
|
||||
Item {
|
||||
id: monitorName
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: root.theme.monitorLabelTop
|
||||
z: 2
|
||||
width: Math.min(nameText.implicitWidth + root.theme.monitorNamePadding * 10, column.width)
|
||||
height: nameText.implicitHeight + root.theme.monitorNamePadding
|
||||
radius: height / 4
|
||||
color: root.theme.barBg
|
||||
border.width: column.isCurrentColumn ? 2 : 1
|
||||
border.color: column.isCurrentColumn ? root.theme.fieldBorder : root.theme.barBorder
|
||||
|
||||
Glass {
|
||||
anchors.fill: parent
|
||||
theme: root.theme
|
||||
radius: monitorName.height / 4
|
||||
tint: root.theme.barBg
|
||||
selected: column.isCurrentColumn
|
||||
shadow: true
|
||||
}
|
||||
|
||||
Text {
|
||||
id: nameText
|
||||
|
||||
@@ -58,12 +58,18 @@ PanelWindow {
|
||||
return event.key === Qt.Key_G && ctrl;
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Glass {
|
||||
anchors.fill: parent
|
||||
theme: root.theme
|
||||
radius: root.theme.cornerRadius
|
||||
color: root.theme.barBg
|
||||
border.color: root.theme.barBorder
|
||||
border.width: 1
|
||||
tint: root.theme.barBg
|
||||
selected: false
|
||||
// The window is only as big as the bar, so a shadow would be cut off.
|
||||
shadow: false
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
@@ -92,15 +98,20 @@ PanelWindow {
|
||||
font.pixelSize: root.theme.fontSize
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Item {
|
||||
id: field
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width - label.width - okButton.width - root.theme.logoSize - root.theme.barSpacing * 3
|
||||
height: root.theme.barHeight - root.theme.barPadding * 2
|
||||
radius: root.theme.cornerRadius / 2
|
||||
color: root.theme.fieldBg
|
||||
border.color: nameField.activeFocus ? root.theme.fieldBorder : root.theme.barBorder
|
||||
border.width: 1
|
||||
|
||||
Glass {
|
||||
anchors.fill: parent
|
||||
theme: root.theme
|
||||
radius: root.theme.cornerRadius / 2
|
||||
tint: root.theme.fieldBg
|
||||
selected: nameField.activeFocus
|
||||
shadow: false
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: nameField
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
readonly property color barBg: "#f00b0e14"
|
||||
readonly property color barBg: "#731a1e2a"
|
||||
readonly property color barBorder: "#40ffffff"
|
||||
readonly property color textColor: "#ffffff"
|
||||
readonly property color labelColor: "#a9b1d6"
|
||||
readonly property color fieldBg: "#332a2e3a"
|
||||
readonly property color fieldBg: "#4d0b0e14"
|
||||
readonly property color fieldBorder: "#7aa2f7"
|
||||
readonly property color cardBg: "#cc1a1e2a"
|
||||
readonly property color cardBg: "#661a1e2a"
|
||||
readonly property color buttonBg: "#7aa2f7"
|
||||
readonly property color buttonText: "#0b0e14"
|
||||
|
||||
// ── glass ───────────────────────────────────────────────────────────
|
||||
|
||||
// Bars and cards are see-through glass. A rim catches the light along
|
||||
// the top and fades toward the bottom, a soft shine lies over the top
|
||||
// half, and a shadow sits underneath.
|
||||
readonly property color glassRimTop: "#8cffffff"
|
||||
readonly property color glassRimBottom: "#14ffffff"
|
||||
readonly property color glassShine: "#29ffffff"
|
||||
// Selected glass: a blue tint and a blue rim.
|
||||
readonly property color glassSelectedTint: "#66283a5e"
|
||||
readonly property color glassSelectedRimBottom: "#807aa2f7"
|
||||
readonly property color glassShadow: "#59000000"
|
||||
readonly property real glassShadowBlur: 24
|
||||
readonly property real glassShadowOffset: 8
|
||||
|
||||
readonly property real cornerRadius: 12
|
||||
readonly property real barHeight: 84
|
||||
readonly property real barWidth: 800
|
||||
@@ -96,7 +111,7 @@ QtObject {
|
||||
readonly property real loopStartScale: 0.6
|
||||
readonly property int loopExpandDuration: 280
|
||||
|
||||
readonly property color loopCardBg: "#e61a1e2a"
|
||||
readonly property color loopCardBg: "#991a1e2a"
|
||||
readonly property real loopCardWidth: 440
|
||||
readonly property real loopCardHeight: 320
|
||||
readonly property real loopCardRadius: 16
|
||||
|
||||
@@ -3,7 +3,7 @@ import Quickshell
|
||||
import Quickshell.Wayland
|
||||
|
||||
// One window on the window loop: a preview with the icon, title and app below.
|
||||
Rectangle {
|
||||
Item {
|
||||
id: root
|
||||
|
||||
required property Theme theme
|
||||
@@ -34,11 +34,15 @@ Rectangle {
|
||||
|
||||
width: root.theme.loopCardWidth
|
||||
height: root.theme.loopCardHeight
|
||||
radius: root.theme.loopCardRadius
|
||||
color: root.theme.loopCardBg
|
||||
border.width: root.selected ? 3 : 1
|
||||
border.color: root.selected ? root.theme.fieldBorder : root.theme.barBorder
|
||||
antialiasing: true
|
||||
|
||||
Glass {
|
||||
anchors.fill: parent
|
||||
theme: root.theme
|
||||
radius: root.theme.loopCardRadius
|
||||
tint: root.theme.loopCardBg
|
||||
selected: root.selected
|
||||
shadow: true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: previewArea
|
||||
@@ -49,6 +53,9 @@ Rectangle {
|
||||
anchors.margins: root.theme.loopCardPadding
|
||||
radius: root.theme.loopPreviewRadius
|
||||
color: root.theme.loopPreviewBg
|
||||
// A faint edge, so it reads as a pane set into the glass.
|
||||
border.width: 1
|
||||
border.color: root.theme.glassRimBottom
|
||||
clip: true
|
||||
|
||||
// Holds the live view and the snapshot. Once a picture is ready it
|
||||
@@ -183,7 +190,7 @@ Rectangle {
|
||||
// Darkens cards toward the back of the loop.
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: parent.radius
|
||||
radius: root.theme.loopCardRadius
|
||||
color: "black"
|
||||
opacity: root.shade * root.theme.loopBackShade
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import QtQuick
|
||||
import Quickshell
|
||||
import QtQuick.Layouts
|
||||
|
||||
Rectangle {
|
||||
Item {
|
||||
id: root
|
||||
|
||||
required property Theme theme
|
||||
@@ -21,11 +21,6 @@ Rectangle {
|
||||
|
||||
width: root.theme.cardWidth
|
||||
height: root.theme.cardHeight
|
||||
radius: root.theme.cardRadius
|
||||
color: root.theme.cardBg
|
||||
border.width: root.selected ? 3 : 1
|
||||
border.color: root.selected ? root.theme.fieldBorder : root.theme.barBorder
|
||||
clip: true
|
||||
|
||||
Behavior on anchors.verticalCenterOffset {
|
||||
enabled: root.animateMoves
|
||||
@@ -47,10 +42,20 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Glass {
|
||||
anchors.fill: parent
|
||||
theme: root.theme
|
||||
radius: root.theme.cardRadius
|
||||
tint: root.theme.cardBg
|
||||
selected: root.selected
|
||||
shadow: true
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: root.theme.fieldPadding
|
||||
spacing: 6
|
||||
clip: true
|
||||
|
||||
// Top row: workspace name + index + current badge
|
||||
RowLayout {
|
||||
|
||||
Reference in new issue
Block a user